local jd = Package:new("jd")

jd.extensionName = "Super_Skeld"

local U = require "packages/utility/utility"

Fk:loadTranslationTable{
  ["jd"] = "Skeld",
  ["sk"] = "Skeld",
}




local sk_n__er = General(jd, "sk_n__er", "skeld", 3, 3,General.Male)
local sk_d__er = General(jd, "sk_d__er", "skeld", 3 ,3 ,General.Male)
sk_d__er.total_hidden = true

Fk:loadTranslationTable{
  ["sk_n__er"] = "ER",
  ["sk_d__er"] = "ER",
  ["#sk_n__er"] = "一切的起点",
  ["designer:sk_n__er"] = "塔罗牌",
  ["cv:sk_n__er"] = "ER",
  ["illustrator:sk_n__er"] = "ER",
}

-- 获得影
local getShade = function (room, n)
  local ids = {}
  for _, id in ipairs(room.void) do
    if n <= 0 then break end
    if Fk:getCardById(id).name == "shade" then
      room:setCardMark(Fk:getCardById(id), MarkEnum.DestructIntoDiscard, 1)
      table.insert(ids, id)
      n = n - 1
    end
  end
  while n > 0 do
    local card = room:printCard("shade", Card.Spade, 1)
    room:setCardMark(card, MarkEnum.DestructIntoDiscard, 1)
    table.insert(ids, card.id)
    n = n - 1
  end
  return ids
end


-- 使命技

local jianqun = fk.CreateTriggerSkill{
  name = "jianqun",
  anim_type = "special",
  frequency = Skill.Quest,
  events = {fk.RoundStart,fk.RoundEnd,fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    if player:getQuestSkillState(self.name) ~= "succeed" and player:getQuestSkillState(self.name) ~= "failed" and player:hasSkill(self) then
      if event == fk.RoundStart then
        return true
      end
      if event == fk.TurnStart then
        if player:hasSkill(self) and target ~= player then
          return not player:isKongcheng()
        end
      end
      if event == fk.RoundEnd and #player:getTableMark("jianqun-givecard") == #Fk:currentRoom().alive_players - 1 then
        return true
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      player:drawCards(#room.alive_players)
      room:notifySkillInvoked(player, self.name, "drawcard")
      room:delay(100)
    end
    if event == fk.TurnStart then
      local card = room:askForCard(player,1,1,false,self.name,false,nil,"#jianqun-chooseCards")
      room:moveCardTo(card, Card.PlayerHand, target, fk.ReasonGive, self.name, nil, false, player.id)
      room:addTableMark(player, "jianqun-givecard", target.id)
      room:notifySkillInvoked(player, self.name, "support")
    end
    if event == fk.RoundEnd then
      if player.general == "sk_n__er" then
        player.general = "sk_d__er"
        room:broadcastProperty(player, "general")
      end
      room:handleAddLoseSkills(player,"n_pofang_active",nil)
      room:handleAddLoseSkills(player,"n_shenquan",nil)
      room:handleAddLoseSkills(player,"n_tiren",nil)
      room:updateQuestSkillState(player,self.name,false)
      room:notifySkillInvoked(player, self.name, "big")
    end
  end,
}

-- 手牌上限

local jianqun_mc = fk.CreateMaxCardsSkill{
  name = "#jianqun_mc",
  correct_func = function(self, player)
    if player:hasSkill(self) then
      return #Fk:currentRoom().alive_players
    end
  end,
}


Fk:loadTranslationTable{
  ["jianqun"] = "建群",
  [":jianqun"] = "使命技，每轮开始时，你摸X张牌并增加X点手牌上限。一名其他角色的回合开始时，你需交给其一张手牌。（X为场上人数）"..
  "<br><strong>成功</strong>：每轮结束时，若你以此法交给了所有其他角色手牌，【建群】失效，然后获得【破防】【神权】【踢人】",

  ["#jianqun-chooseCards"] = "建群:养老院（冲200）为了大家，交出手牌吧！",

  ["$jianqun"] = "玩原神！",
}







-- 破防用 视为



local n_pofang_Viewas = fk.CreateViewAsSkill{
  name = "#n_pofang_viewas",
  handly_pile = true,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).name == "shade"
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    local discard_pile = table.simpleClone(Fk:currentRoom().discard_pile)
    local card,r_card
    if #discard_pile > 1 then
      r_card = Fk:getCardById(discard_pile[#discard_pile])
    else
      r_card = Fk:getCardById(discard_pile[1])
    end
    card = Fk:cloneCard(r_card.name)
    card:addSubcard(cards[1])
    card.skillName = "n_pofang"
    return card
  end,
  before_use = function(self, player, use)
    table.remove(use.card.skillNames, "n_pofang_tag")
    use.card.skillName = "n_pofang"
  end,
}
Fk:addSkill(n_pofang_Viewas)




-- 破防本体

local n_pofang = fk.CreateTriggerSkill{
  name = "#n_pofang",
  anim_type = "special",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove,fk.HpLost,fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if event == fk.AfterCardsMove then
      if not (player:hasSkill(self) and player.phase == Player.NotActive) then return end
      for _, move in ipairs(data) do
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
    end
    if event == fk.HpLost then
      return player:hasSkill(self)
    end
    if event == fk.DamageInflicted then
      return player:hasSkill(self) and target == player
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.dead or player:isNude() then return end
    for i = 1, 2, 1 do
      local moves = {}
      table.insert(moves, {
        ids = getShade(room, 1),
        from = player.id,
        toArea = Card.DrawPile,
        moveReason = fk.ReasonJustMove,
        skillName = self.name,
        drawPilePosition = math.random(1,5*#Fk:currentRoom().alive_players), ---5*#Fk:currentRoom().alive_players
      })
      room:moveCards(table.unpack(moves))
      room:delay(20)
    end
  end,
}

-- 破防转化影
local n_pofang_active = fk.CreateActiveSkill{
  name = "n_pofang_active",
  anim_type = "masochism",
  card_num = 0,
  target_num = 0,
  attached_skill_name = "n_pofang_other&",
  prompt = function (self)
    local discard_pile = table.simpleClone(Fk:currentRoom().discard_pile)
    if discard_pile == nil then return false end
    if #discard_pile > 1 then
      local card = Fk:getCardById(discard_pile[#discard_pile])
      return "#n_pofang_active:::" .. card.trueName
    else
      local card = Fk:getCardById(discard_pile[1])
      return "#n_pofang_active:::" .. card.trueName
    end
  end,
  can_use = function(self, player,room)
    local discard_pile = table.simpleClone(Fk:currentRoom().discard_pile)
    local a = 0
    for _, c in ipairs(Self.player_cards[Player.Hand]) do
      local cd = Fk:getCardById(c)
      if cd.trueName == "shade" then
        a = a + 1
      end
    end
    if a == 0 then return false end
    if discard_pile == nil then return false end
    if discard_pile == 0 then return false end
    if #discard_pile > 1 then
      local card = Fk:getCardById(discard_pile[#discard_pile])
      card = Fk:cloneCard(card.name)
      if card.type ~= Card.TypeEquip and
        card.trueName ~= "jink" and
        card.trueName ~= "nullification" then
        return player:hasSkill(self) and #discard_pile ~= 0
      end
    elseif #discard_pile == 1 then
      local card = Fk:getCardById(discard_pile[#discard_pile])
      card = Fk:cloneCard(card.name)
      if card.type ~= Card.TypeEquip and
      card.trueName ~= "jink" and
      card.trueName ~= "nullification" and
      player:canUse(Fk:cloneCard(card.trueName)) then
        return player:hasSkill(self) and #discard_pile ~= 0
      end
    else
      return false
    end
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local success, dat = player.room:askForUseActiveSkill(player, "#n_pofang_viewas", "#n_pofang-use", true)
    if success then
      room:setPlayerMark(player,"pofang_dsm",1)
      local card = Fk.skills["#n_pofang_viewas"]:viewAs(dat.cards)
      local discard_pile = table.simpleClone(Fk:currentRoom().discard_pile)
      local ids = {}
      local a = 1
      for _, cid in ipairs(discard_pile) do
        if a == #discard_pile then
          table.insert(ids,cid)
          break
        end
        a = a + 1
      end
      local moves = {}
      table.insert(moves, {
        ids = ids,
        from = player.id,
        toArea = Card.DrawPile,
        moveReason = fk.ReasonJustMove,
        skillName = self.name,
        drawPilePosition = #Fk:currentRoom().draw_pile,
      })
      room:useCard{
      from = player.id,
      tos = table.map(dat.targets, function(id) return {id} end),
      card = card,
      }
      local pile = player:getPile("@n_pofang_e")
      if #pile ~= 0 then
        for _, c in ipairs(pile) do
          t_card = c
          break
        end
        room:moveCardTo(t_card, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, "@n_pofang_e", true, player.id)
      else
        room:moveCards(table.unpack(moves))
      end
    end
  end,
}

-- 破防其他角色
local n_pofang_other = fk.CreateActiveSkill{
  name = "n_pofang_other&",
  anim_type = "masochism",
  card_num = 2,
  max_cards = 2,
  target_num = 1,
  prompt = "#n_pofang_other_promot&",
  target_filter = function (self, to_select, selected)
    return #selected == 0 and Fk:currentRoom():getPlayerById(to_select):hasSkill("n_pofang_active")
  end,
  can_use = function(self, player,room)
    return #Self.player_cards[Player.Hand] >= 2 and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    target:addToPile("@n_pofang_e", effect.cards, true, self.name)
    player:drawCards(2,self.name)
    local use = player.room:askForUseCard(player, "slash", "slash", "#pofang-slash", true, nil)
    if use then
      room:useCard(use)
    end
  end,
}



Fk:loadTranslationTable{
  ["#n_pofang"] = "破防",
  ["n_pofang_active"] = "破防",
  [":n_pofang_active"] = "锁定技，当你失去体力/受到伤害/于回合外失去手牌时，你将2张【影】洗入牌堆的前5X张牌中。你可以将一张【影】当作弃牌堆牌堆顶的不为闪或装备牌的牌使用，然后若你有【恶】，你弃置你最早置入的【恶】，否则你将此牌置于牌堆底。<br>"..
  "其他角色出牌阶段限一次，其可以将两张手牌置于你的武将牌上称为【恶】并摸两张牌，然后其可以对你使用一张无距离限制的【杀】。（X为场上人数）",
  ["#n_pofang_active"] = "你可以将一张【影】当作 %arg 使用",
  ["#n_pofang-use"] = "使用此牌",
  ["@n_pofang_e"] = "恶",

  ["n_pofang_other&"] = "破防",
  ["#n_pofang_other_promot&"] = "该死的er，我要起义！！！",

  ["$n_pofang_active"] = "傻鸟!",
  ["#n_pofang_viewas"] = "破防",


}

















-- 神权

local n_shenquan = fk.CreateTriggerSkill{
  name = "n_shenquan",
  anim_type = "control",
  events = {fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(3)
    U.viewCards(player, cards, self.name)
    local discard_pile = table.simpleClone(Fk:currentRoom().discard_pile)
    if #discard_pile > 2 then
      if room:askForSkillInvoke(player, self.name, nil, "#shenquan-askforpile") then
        local ids = {}
        for _, cid in ipairs(discard_pile) do
          if #ids == 3 then
            break
          end
          table.insert(ids,cid)
        end
        local moves = {}
        table.insert(moves, {
          ids = ids,
          from = player.id,
          toArea = Card.DrawPile,
          moveReason = fk.ReasonJustMove,
          skillName = self.name,
          drawPilePosition = 1,
        })
        room:moveCards(table.unpack(moves))
        player:addToPile("@n_pofang_e", cards, true, self.name)
      end
    end
    local shades = getShade(room, 1)
    room:obtainCard(player, shades, true, fk.ReasonPrey, player.id, self.name)
  end,
}


Fk:loadTranslationTable{
  ["n_shenquan"] = "神权",
  [":n_shenquan"] = "回合开始时，你可以观看牌堆顶的三张牌，然后若弃牌堆的牌数不少于3，你可以将弃牌堆牌堆顶的三张牌置于牌堆顶，若如此做，你将你观看过的牌变为【恶】。最后你从游戏外获得一张【影】。",
  ["#shenquan-askforpile"] = "是否胡作非为，把牌堆顶你不满意的牌丢了",

  ["$n_shenquan"] = "肯定是玩原神玩多了",

}








-- 踢人

local n_tiren = fk.CreateTriggerSkill{
  name = "n_tiren",
  frequency = Skill.Limited,
  anim_type = "defensive",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return player == target and player.phase == Player.Play and
      player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and #player:getPile("@n_pofang_e") >= 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local pile = player:getPile("@n_pofang_e")
    local t_card = {}
    local a = 0
    for _, c in ipairs(pile) do
      table.insert(t_card,c)
      local cd = Fk:getCardById(c)
      if cd.trueName == "shade" then
        a = a + 1
      end
    end
    room:moveCardTo(t_card, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, "@n_pofang_e", true, player.id)
    room:shuffleDrawPile()
    if a ~= 0 then
      local moves = {}
      table.insert(moves, {
        ids = getShade(room, a),
        from = player.id,
        toArea = Card.DrawPile,
        moveReason = fk.ReasonJustMove,
        skillName = self.name,
        drawPilePosition = math.random(1,#Fk:currentRoom().draw_pile), ---Fk:currentRoom()..draw_pile
      })
      room:moveCards(table.unpack(moves))
    end
    room:endTurn()
    local throw = room:askForCard(player,1,player:getHandcardNum(),false,self.name,true,".|.|.|.|.","#tiren-throw")
    if #throw ~= 0 then
      room:moveCardTo(throw, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, nil, true, player.id)
      for i = 1, 2, 1 do
        local moves = {}
        table.insert(moves, {
          ids = getShade(room, 1),
          from = player.id,
          toArea = Card.DrawPile,
          moveReason = fk.ReasonJustMove,
          skillName = self.name,
          drawPilePosition = math.random(1,5*#Fk:currentRoom().alive_players), ---5*#Fk:currentRoom().alive_players
        })
        room:moveCards(table.unpack(moves))
        room:delay(20)
      end
      player:gainAnExtraTurn(true, self.name)
    end
  end,
}

Fk:loadTranslationTable{
  ["n_tiren"] = "踢人",
  [":n_tiren"] = "限定技，出牌阶段结束时，若你有【恶】，你可以弃置所有【恶】并洗牌，其中每有一个【影】，你将一张【影】洗入牌堆，然后你结束回合，最后你可以弃置任意张手牌，若如此做，你执行一个额外回合。",
  ["#tiren-throw"] = "你可以弃置任意张手牌执行一个额外回合",
  ["$n_tiren"] = "傻鸟傻鸟傻鸟傻鸟傻鸟",
}












Fk:addSkill(n_pofang_other)
jianqun:addRelatedSkill(jianqun_mc)
n_pofang_active:addRelatedSkill(n_pofang)
sk_n__er:addSkill(jianqun)
sk_n__er:addRelatedSkill(n_pofang_active)
sk_n__er:addRelatedSkill(n_shenquan)
sk_n__er:addRelatedSkill(n_tiren)






local sk__luhun = General:new(jd, "sk__luhun", "skeld", 3 ,3 ,General.Male)
sk__luhun.shield = 1
local zhumian = fk.CreateTriggerSkill{
  name = "ld__zhumian",
  mute = true,
  derived_piles = "sk___luhun_power",
  events = {fk.Damaged, fk.Damage},
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(self) or player.dead then return false end
    if event == fk.Damaged then return player:getMark("_ld__zhumian_damaged-turn") ~= 2 and #player:getPile("sk___luhun_power")<=7
    else return player:getMark("_ld__zhumian_damage-turn") ~= 2 end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name)
    if event == fk.Damaged then
      room:notifySkillInvoked(player, self.name, "masochism")
    else
      room:notifySkillInvoked(player, self.name, "drawcard")
    end
    player:drawCards(1, self.name)
    if not player:isNude() then
      local card = room:askForCard(player, 1, 1, true, self.name, false, nil, "#ld__zhumian-push")
      player:addToPile("sk___luhun_power", card, true, self.name)
    end
  end,
}
local zhumian_maxcards = fk.CreateMaxCardsSkill{
  name = "#ld__zhumian_maxcards",
  correct_func = function(self, player)
    return player:hasSkill(self) and #player:getPile("sk___luhun_power") or 0
  end,
}
zhumian:addRelatedSkill(zhumian_maxcards)
local chimian = fk.CreateActiveSkill{
  name = "ld__chimian",
  anim_type = "control",
  prompt = function(self)
    return "#ld__chimian-active:::" .. #Self:getPile("sk___luhun_power")-1
  end,
  card_num = 1,
  target_num = 1,
  expand_pile = "sk___luhun_power",
  can_use = function(self, player)
    return #player:getPile("sk___luhun_power") > 0 and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  target_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Self:getPileNameOfId(to_select) == "sk___luhun_power"
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:moveCardTo(effect.cards, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, "sk___luhun_power", true, player.id)
    if not target.dead then
      room:drawCards(target, #player:getPile("sk___luhun_power"), self.name)
    end
    room:damage{
      to = player,
      damage = 1,
      damageType = fk.NormalDamage,
      skillName = self.name,
    }
  end,
}
local famian = fk.CreateTriggerSkill{
  name = "famian",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player.phase == Player.Finish and #player:getPile("sk___luhun_power") > 1
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askForCard(player, 2, 2, false, self.name, true, ".|.|.|sk___luhun_power|.|.", "#famian-invoke", "sk___luhun_power")
    if #cards == 2 then
      self.cost_data = cards
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:moveCardTo(self.cost_data, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, nil, true, player.id)
    local targets = table.map(room:getAlivePlayers(), Util.IdMapper)
    local to = room:askForChoosePlayers(player, targets, 1, 1, "#famian-choose", self.name, false)
    to = room:getPlayerById(to[1])
    local card = {}
    if not to:isKongcheng() then
      card = room:askForCard(to, 1, 1, false, self.name, true, "peach", "#famian-card:"..player.id)
    end
    if #card > 0 then
      to:showCards(card)
      local p = room:askForChoosePlayers(player, table.map(room:getAlivePlayers(), Util.IdMapper), 1, 1,
        "#famian-give:::"..Fk:getCardById(card[1]):toLogString(), self.name, false)
      if p ~= to.id then
        p = room:getPlayerById(p[1])
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonGive, self.name, nil, true, player.id)
      end
    else
      room:loseHp(to, 1, self.name)
      if not to.dead and #to:getCardIds("he") > 0 then
        local id = room:askForCardChosen(player, to, "he", self.name)
        to:addToPile(self.name, id, true, self.name)
      end
    end
  end,
}
local famian_delay = fk.CreateTriggerSkill{
  name = "#famian_delay",
  mute = true,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return target == player and #player:getPile("famian") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
  end,
}
famian:addRelatedSkill(famian_delay)
sk__luhun:addSkill(zhumian)
sk__luhun:addSkill(chimian)
sk__luhun:addSkill(famian)
Fk:loadTranslationTable{
  ["sk__luhun"] = "陆浑",
  ["#sk__luhun"] = "撸昏的面王",
  ["designer:sk__luhun"] = "塔罗牌",
  ["cv:sk__luhun"] = "luhunee7",
  ["illustrator:sk__luhun"] = "luhunee7",
  ["ld__zhumian"] = "煮面",
  [":ld__zhumian"] = "当你受到伤害后或造成伤害时，你可以摸一张牌，然后将一张牌置于武将牌上（称为“面”）；你的手牌上限+X（X为“面”数）。",
  ["ld__chimian"] = "吃面",
  [":ld__chimian"] = "出牌阶段限一次，你可以吃面，将一张“面”置入弃牌堆并选择一名角色，其摸X张牌，然后你受到一点无来源伤害（X为“面”的数量且至多为5）。",
  ["#ld__zhumian-push"] = "吃面：将一张牌置于武将牌上（称为“面“）",
  ["#ld__chimian-active"] = "发动吃面，选择一张“面”牌置入弃牌堆并选择一名角色，令其摸 %arg 张牌",
  ["sk___luhun_power"] = "面",
  ["$ld__zhumian1"] = "唯一缺点，是太过完美！",
  ["$ld__zhumian2"] = "我们这个群是绿色文明群",
  ["$ld__zhumian3"] = "我错了你是我父亲",
  ["$ld__zhumian4"] = "我不是傻子",
  ["$ld__chimian1"] = "*嗦面声.......好吃",
  ["$ld__chimian2"] = "吃一口面 *嗦面声",
  ["$famian1"] = "朕宁拼一死，逆贼安敢一战!",
  ["$famian2"] = "你怎么骂人呢！",
  ["~sk__luhun"] = "怎么了，你累了？说好的，蒸批呢……",
  ["famian"] = "丢面",
  [":famian"] = "结束阶段开始时，你可以将两张“面“置入弃牌堆。若如此做，你须指定一名角色并令其选择一项:1.亮出一张【桃】，然后由你交给任意一名角色。2.该角色失去1点体力，然后由你选择将其一张牌移出游戏。",
  ["#famian-invoke"] = "你可以弃置两张“面”，若如此做，你可以发动丢面，",
  ["#famian-choose"] = "选择丢面目标",
  
}



















local sk__hmzmg = General:new(jd, "sk__hmzmg", "skeld", 3 ,3 ,General.Male)
local hamuu = fk.CreateTriggerSkill{
  name = "hamuu",
  anim_type = "special",
  derived_piles = "hmzmg_hm",
  frequency = Skill.Compulsory,
  events = {fk.CardUsing, fk.TargetConfirmed,fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and
      #player:getPile("hmzmg_hm") < 4 + player:getMark("hamuu_extra") then
      return event == fk.CardUsing
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local scar_id =room:getNCards(1)[1]
    local scar = Fk:getCardById(scar_id)
    player:broadcastSkillInvoke(self.name)
    player:addToPile("hmzmg_hm", scar, true, self.name)
  end,
}
local hamuu_delay = fk.CreateTriggerSkill{
  name = "#hamuu_delay",
  frequency = Skill.Compulsory,
  mute = true,
  events = {fk.DrawNCards, fk.EventPhaseStart},
  derived_piles = "hmzmg_hm",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or player ~= target then return false end
    if event == fk.DrawNCards and #player:getPile("hmzmg_hm") > 0 then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DrawNCards then
      room:notifySkillInvoked(player, self.name, "drawcard")
      player:broadcastSkillInvoke(self.name)
      data.n = data.n + #player:getPile("hmzmg_hm")
    end
  end,
}
local haamu = fk.CreateActiveSkill{
  name = "haamu",
  anim_type = "control",
  prompt = function(self)
    return "#haamu-active:::" .. 2
  end,
  card_num = 0,
  can_use = function(self, player)
    return #player:getPile("hmzmg_hm") > 1 and player:usedSkillTimes(self.name, Player.HistoryPhase) <= 1
  end,
  target_filter = Util.FalseFunc,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Self:getPileNameOfId(to_select) == "hmzmg_hm"
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.from)
    local cards = player.room:askForCard(player, 2, 2, false, self.name, true, ".|.|.|hmzmg_hm|.|.", "#haamu-invoke", "hmzmg_hm")
    player:broadcastSkillInvoke(self.name)
    room:moveCardTo(cards, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, self.name, nil, true, player.id)
    room:doIndicate(player.id, {target.id})
    room:drawCards(target,2, self.name)
    local card = room:askForCardChosen(player, target, "he", self.name)
    room:throwCard({card}, self.name, target, player)
end,
}
hamuu:addRelatedSkill(hamuu_delay)
sk__hmzmg:addSkill(hamuu)
sk__hmzmg:addSkill(haamu)
Fk:loadTranslationTable{
  ["sk__hmzmg"] = "哈姆字母哥",
  ["#sk__hmzmg"] = "哈姆？哈姆！",
  ["designer:sk__hmzmg"] = "塔罗牌",
  ["cv:sk__hmzmg"] = "字母哥",
  ["illustrator:sk__hmzmg"] = "字母哥",
  ["hmzmg_hm"] = "哈姆",
  ["hamuu"] = "哈姆？",
  ["hamuu_delay"] = "哈姆？",
  [":hamuu"] = "锁定技，当你使用牌时，你将牌堆顶的一张牌置于武将牌上称为【哈姆】，摸牌阶段，你多摸【哈姆】数张牌",
  ["haamu"] = "哈姆！",
  [":haamu"] = "出牌阶段限两次，你可以移去两张【哈姆】，摸两张牌然后弃置一张牌",
  ["$hamuu1"] = "哈姆？哈姆！",
  ["$haamu1"] = "哈姆？哈姆！",
  ["$hamuu2"] = "哈姆？哈姆！",
  ["$haamu2"] = "哈姆？哈姆！",
  ["#haamu-invoke"] = "选择要弃置的【哈姆】",
  ["#haamu-active"] = "是否发动【哈姆！】",
  ["#hamuu_delay"] = "哈姆？哈姆！",
  ["~sk__hmzmg"] = "哈姆？哈姆！",
}







































local sk__gg = General:new(jd, "sk__gg", "skeld", 1 ,3 ,General.Male)

local zisha = fk.CreateTriggerSkill{
  name = "zisha",
  events = {fk.DamageInflicted},
  anim_type = "defensive",
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return
      target == player and
      player:hasSkill(self) and
      player.maxHp > 1 and
      player.hp == 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageInflicted and target == player then
      room:drawCards(player,2*data.damage)
      room:changeMaxHp(player, -data.damage)
      return true
    end
  end,
}
local zishaHp = fk.CreateTriggerSkill{
  name = "#zisha-hp",
  events = {fk.GameStart},
  anim_type = "defensive",
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return
      player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.GameStart then
      local room = player.room
      local num = 0
      for _, p in ipairs(room:getAlivePlayers()) do
        if not p.dead then
          num = num +1
        end
        if num >=5 then
          num = 5
        end
      end
      room:changeMaxHp(player,num)
    end
  end
}
local zishaBuff = fk.CreateMaxCardsSkill {
  name = "#zisha-buff",
  frequency = Skill.Compulsory,
  fixed_func = function(self, player)
    return player:hasSkill("zisha") and player.maxHp or nil
  end
}
local yuyuz = fk.CreateTriggerSkill{
  name = "yuyuz",
  frequency = Skill.Wake,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      player.phase == Player.Start and
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    return player.maxHp<=4
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num = 0
    for _, p in ipairs(room:getAlivePlayers()) do
      if not p.dead then
        num = num +1
      end
      if num >=3 then
        num = 3
      end
    end
    room:changeMaxHp(player,num)
    room:handleAddLoseSkills(player, "xiuzhan", nil)
    room:handleAddLoseSkills(player, "ziwei", nil)
    player:addMark("tl_zican",3)
  end,
}
local zican = fk.CreateActiveSkill{
  name = "zican",
  anim_type = "masochism",
  card_num = 0,
  target_num = 0,
  prompt = "#zican",
  can_use = function(self, player,room)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) < 2
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    if player:getMark("tl_zican")==3 then
      if player.hp~=1 then
        room:drawCards(player,2)
      end
      room:damage({
        to = player,
        damage = 1,
        damageType = fk.NormalDamage,
        skillName = self.name,
      })
    else
      room:drawCards(player,1)
      room:changeMaxHp(player, -1)
    end
  end,
}
local ziwei = fk.CreateActiveSkill{
  name = "ziwei",
  anim_type = "switch",
  prompt = "#ziwei",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1 and not player:isKongcheng() and player.maxHp <= 5 and player:getHandcardNum() > 2
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local cards = player.room:askForCard(player, 3, 3, true, self.name, false, "", "#ziwei-invoke")
    room:changeMaxHp(player, 1)
    room:throwCard({cards}, self.name, player, player)
    room:drawCards(player,1)
  end,
}

local xiuzhan = fk.CreateActiveSkill{
  name = "xiuzhan",
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  frequency = Skill.Limited,
  prompt = "#xiuzhan",
  interaction = function()
    return UI.Spin {
      from = 1,
      to = Self.maxHp-1,
    }
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and player.maxHp > 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local tolose = self.interaction.data
    room:changeMaxHp(player, -tolose)
    if player.dead then return end
    local tos = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, tolose, "#xiuzhan-choose", self.name, true)
    for _, pid in ipairs(tos) do
      local p = room:getPlayerById(pid)
      local mark = p:getTableMark("@@xiuzhan")
      table.insertIfNeed(mark, player.id)
      room:setPlayerMark(p, "@@xiuzhan", mark)
    end
    room:drawCards(player,2*tolose)
  end,
}
local xiuzhan_delay = fk.CreateTriggerSkill{
  name = "#xiuzhan_delay",
  refresh_events = {fk.TurnStart, fk.Death},
  mute = true,
  can_refresh = function(self, event, target, player, data)
    return target == player
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room.alive_players) do
      local mark = p:getTableMark("@@xiuzhan")
      if table.contains(mark, player.id) then
        table.removeOne(mark, player.id)
        room:setPlayerMark(p, "@@xiuzhan", #mark > 0 and mark or 0)
      end
    end
  end,
}
local xiuzhan_prohibit = fk.CreateProhibitSkill{
  name = "#xiuzhan_prohibit",
  is_prohibited = function(self, from, to)
    local mark = from:getTableMark("@@xiuzhan")
    return #mark > 0 and from ~= to
  end,
}

xiuzhan:addRelatedSkill(xiuzhan_prohibit)
xiuzhan:addRelatedSkill(xiuzhan_delay)
zisha:addRelatedSkill(zishaBuff)
zisha:addRelatedSkill(zishaHp)
sk__gg:addSkill(zisha)
sk__gg:addSkill(zican)
sk__gg:addSkill(yuyuz)
sk__gg:addRelatedSkill(xiuzhan)
sk__gg:addRelatedSkill(ziwei)
Fk:loadTranslationTable{
  ["sk__gg"] = "狗嗝",
  ["#sk__gg"] = "我承认我做不到",
  ["designer:sk__gg"] = "塔罗牌",
  ["cv:sk__gg"] = "AI",
  ["illustrator:sk__gg"] = "狗嗝",
  ["zisha"] = "紫砂",
  [":zisha"] = "锁定技，你的手牌上限为你的体力上限；当你受到伤害时，若你的体力上限大于1且体力值为1，防止其并改为减少等量体力上限，然后你摸失去量两倍的牌；游戏开始时，你增加X点体力上限（X为场上存活角色数且至多为5）",
  ["zican"] = "紫残",
  [":zican"] = "出牌阶段，你可以减少1点体力上限并摸一张牌<br>修改后：出牌阶段限两次，你可以受到1点无来源伤害并摸两张牌",
  ["#zisha-hp"] = "紫砂",
  ["#zican"] = "我承认我做不到",
  ["xiuzhan"] = "休战",
  [":xiuzhan"] = "限定技，出牌阶段，你可以失去任意点体力上限，令任意名角色获得“休战”标记直到你的下回合开始或死亡；拥有“休战”标记的角色使用牌只能指定其自己为目标。",
  ["@xiuzhan-turn"] = "休战",
  ["#xiuzhan"] = "休战：可失去任意点体力上限，摸两倍的牌，然后使任意名角色获得“休战”效果",
  ["@@xiuzhan"] = "休战",
  ["#xiuzhan-choose"] = "你们不要再打了辣！",
  ["$xiuzhan1"] = "你们不要再打了辣！",
  ["$xiuzhan2"] = "我有抑郁症",
  ["$ziwei2"] = "我承认我做不到",
  ["$ziwei1"] = "我有抑郁症",
  ["$zican1"] = "我承认我做不到",
  ["$zican2"] = "我有抑郁症",
  ["$zisha1"] = "我承认我做不到",
  ["$zisha2"] = "我有抑郁症",
  ["yuyuz"] = "玉玉",
  [":yuyuz"] = "觉醒技，准备阶段，若你的体力上限不多于4，你增加X点体力上限，获得【休战】（X为场上存活角色数且至多为3），获得【紫薇】并修改【紫残】。",
  ["$yuyuz1"] = "喝，还拿旧眼光看我呢",
  ["$yuyuz2"] = "我有抑郁症",
  ["ziwei"] = "紫薇",
  [":ziwei"] = "出牌阶段限一次，若你的体力上限不多于5，你可以弃置三张牌并摸一张牌，然后回复1点体力上限",
  ["#ziwei"] = "弃置三张牌，回复体力上限",
  ["#ziwei-invoke"] = "选择要弃的牌",
  ["~sk__gg"] = "我有抑郁症...",

}







































local sk__mmc = General:new(jd, "sk__mmc", "skeld", 1 ,1 ,General.Male)
Fk:loadTranslationTable{
  ["sk__mmc"] = "MMC",
  ["#sk__mmc"] = "生生不息",
  ["designer:sk__mmc"] = "塔罗牌",
  ["cv:sk__mmc"] = "AI//OTTO",
  ["illustrator:sk__mmc"] = "MMC",
}
local shenggen = fk.CreateTriggerSkill{
  name = "shenggen",
  anim_type = "masochism",
  frequency = Skill.Compulsory,
  events = {fk.GameStart,fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart and player:hasSkill(self) then return true end
    if event == fk.CardUseFinished and player:hasSkill(self) and player:getMark("@mmc_cdus") >= 8 then return true end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if (event == fk.GameStart) then
      local targets = table.filter(room:getOtherPlayers(player), function(p) return p :getMark("@@mmc_target_time") == (nil or 0) end)
      if #targets == 0 then return false end
      local tos = player.room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#shengcao-choose", "shengcao", false)
      if #tos > 0 then
        self.cost_data = {tos = tos}
        return true
      end
    end
    if event == fk.Damage and data.to:getMark("@@mmc_target_time") == 0 then
      return true
    end
    if event == fk.CardUseFinished and player:hasSkill(self) and player:getMark("@mmc_cdus") >= 8 then
      local targets = table.filter(room:getOtherPlayers(player), function(p) return p :getMark("@@mmc_target_time") == (nil or 0) end)
      if #targets == 0 then return false end
      local tos = player.room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#shengcao-choose", "shengcao", false)
      if #tos > 0 then
        self.cost_data = {tos = tos}
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = room:getPlayerById(self.cost_data.tos[1])
    if event == fk.GameStart then
      room:doIndicate(player.id, {tos.id})
      room:setPlayerMark(tos,"@@mmc_target_time",1)
      room:addPlayerMark(player,"@mmc_cdus",5)
      while true do
        if player.maxHp > 1 then
          room:changeMaxHp(player, -1)
        else
          break
        end
      end
    end
    if event == fk.CardUseFinished and player:hasSkill(self) and player:getMark("@mmc_cdus") >= 8 then
      room:addPlayerMark(player,"@mmc_cdus",-8)
      room:doIndicate(player.id, {tos.id})
      room:setPlayerMark(tos,"@@mmc_target_time",1)
    end
  end
}
local shenggen_viewas = fk.CreateFilterSkill{
  name = "#shenggen_viewas",
  pattern = "slash",
  main_skill = shenggen,
  mute = true,
  frequency = Skill.Compulsory,
  anim_type = "offensive",
  card_filter = function(self, card, player)
    return player:hasSkill(self) and card.name == "jink" and table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, to_select)
    return Fk:cloneCard("slash", to_select.suit, to_select.number)
  end,
}
local shenggen_viewas_2 = fk.CreateFilterSkill{
  name = "#shenggen_viewas_2",
  pattern = "slash",
  main_skill = shenggen,
  mute = true,
  frequency = Skill.Compulsory,
  anim_type = "offensive",
  card_filter = function(self, card, player)
    return player:hasSkill(self) and card.name == "peach" and table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, to_select)
    return Fk:cloneCard("jink", to_select.suit, to_select.number)
  end,
}
local shenggen_viewas_3 = fk.CreateFilterSkill{
  name = "#shenggen_viewas_3",
  pattern = "slash",
  main_skill = shenggen,
  mute = true,
  frequency = Skill.Compulsory,
  anim_type = "offensive",
  card_filter = function(self, card, player)
    return player:hasSkill(self) and card.name == "analeptic" and table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, to_select)
    return Fk:cloneCard("peach", to_select.suit, to_select.number)
  end,
}
local shenggen_viewas_4 = fk.CreateFilterSkill{
  name = "#shenggen_viewas_4",
  pattern = "slash",
  main_skill = shenggen,
  mute = true,
  frequency = Skill.Compulsory,
  anim_type = "offensive",
  card_filter = function(self, card, player)
    return player:hasSkill(self) and card.name == "nullification" and table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, to_select)
    return Fk:cloneCard("enemy_at_the_gates", to_select.suit, to_select.number)
  end,
}
local shenggen_trigger = fk.CreateTriggerSkill{
  name = "#shenggen_trigger",
  anim_type = "masochism",
  main_skill = shenggen,
  events = {fk.CardRespondFinished, fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player:getMark("@mmc_cdus") < 8 then
      return player:hasSkill(shenggen)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local tos = {player.id}
    if #tos > 0 then
      self.cost_data = tos[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMark("@mmc_cdus") <= 8 then
      room:addPlayerMark(player,"@mmc_cdus",1)
    end
    while true do
      if player.maxHp > 1 then
        room:changeMaxHp(player, -1)
      else
        break
      end
    end
  end,
}
shenggen:addRelatedSkill(shenggen_trigger)
shenggen:addRelatedSkill(shenggen_viewas)
shenggen:addRelatedSkill(shenggen_viewas_2)
shenggen:addRelatedSkill(shenggen_viewas_3)
shenggen:addRelatedSkill(shenggen_viewas_4)
local shengcao = fk.CreateTriggerSkill{
  name = "shengcao",
  anim_type = "masochism",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EnterDying and player:hasSkill(self) and
    table.find(player.room.alive_players, function(p) return p :getMark("@@mmc_target_time") ~= 0 end) then
      local logic = room.logic
      local dying_event = logic:getCurrentEvent():findParent(GameEvent.Dying, true)
      if dying_event ~= nil and target == player then return true end
      if dying_event == nil and target ~= player then return false end
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    if event == fk.EnterDying then
      local targets = table.filter(room.alive_players, function(p) return p :getMark("@@mmc_target_time") ~= 0 end)
      if #targets == 0 then return false end
      local tos = player.room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#shengcao-choose", "shengcao", true)
      if #tos > 0 then
        self.cost_data = {tos = tos}
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
      if player.hp<=0 then
        room:recover{
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name
        }
      for _, p in ipairs(room:getOtherPlayers(player, true)) do
        if not p:isAllNude() and
        p:getMark("@@mmc_target_time") ~= 0 then
          local id = room:askForCardChosen(player, p, "hej", self.name)
          room:obtainCard(player, id, false, fk.ReasonPrey)
          if player.dead then return false end
        end
      end
    end
    room:setPlayerMark(to, "@@mmc_target_time", 0)
  end
}
local shenggen_maxcards = fk.CreateMaxCardsSkill{
  name = "#shenggen_maxcards",
  correct_func = function(self, player)
    if player:hasSkill(shengcao) then
      local amns = 0
      for _, p in ipairs(Fk:currentRoom().alive_players) do
        if p:getMark("@@mmc_target_time") ~= 0 then
          amns = amns + 1
        end
      end
      return amns
    end
  end
}

Fk:loadTranslationTable{
  ["shenggen"] = "生根",
  [":shenggen"] = "①锁定技，一名角色使用手牌时，你获得一枚【草】标记，然后若你拥有至少8枚【草】标记，你使一名没有【草根】的角色获得【草根】标记，你的【草】上限为8。<br>"..
  "②游戏开始时，你使一名角色获得【草根】和5枚【草】。当你的体力上限大于1时，你将体力上限调整至1。<br>"..
  "③你的手牌上限加X（X为全场【草根】数），你的【闪】视为【杀】，【桃】视为【闪】，【酒】视为【桃】，【无懈可击】视为【兵临城下】。",
  ["shengcao"] = "生草",
  [":shengcao"] = "当你进入濒死状态时，你可以选择一名有【草根】的角色，然后你回复1点体力，获得所有有【草根】标记的角色一张牌，最后移去选择角色的【草根】。",
  ["@@mmc_target_time"] = "草根",
  ["#shengcao-choose"] = "你可以选择一名有【草根】的角色，然后发动【生草】",
  ["@mmc_cdus"] = "草",
  ["#shenggen_trigger"] = "草",
  ["#shenggen_viewas"] = "草",
  ["#shenggen_viewas_2"] = "草",
  ["#shenggen_viewas_3"] = "草",
  ["$shenggen1"] = "草!",
  ["$shengcao1"] = "草!",
  ["$shenggen2"] = "操!",
  ["$shengcao2"] = "操!",
  ["~sk__mmc"] = "操！",
}
shenggen:addRelatedSkill(shenggen_maxcards)
sk__mmc:addSkill(shenggen)
sk__mmc:addSkill(shengcao)





























































local sk__nep = General:new(jd, "sk__nep", "skeld", 3, 3,General.Male)
Fk:loadTranslationTable{
  ["sk__nep"] = "涅普屯",
  ["#sk__nep"] = "炼金大师",
  ["designer:sk__nep"] = "塔罗牌",
  ["cv:sk__nep"] = "NEPTUNE",
  ["illustrator:sk__nep"] = "NEPTUNE",
}

local kuangdu = fk.CreateTriggerSkill{
  name = "kuangdu",
  anim_type = "masochism",
  events = {fk.CardUsing},
  frequency = Skill.Limited,
  can_trigger = function(self, event, target, player, data)
    if player:getMark("@@lianjin") == nil or (player:getMark("@@lianjin") == 0 and player:getMark("@@lianjin-turn")) == 0 then
      return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    else
      return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) <=2
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"@kuangdu_time",0)
    for i = 1 ,99999 do
      if not player:isAlive() then return end
      local judge = {
        who = player,
        reason = self.name,
        pattern = ".",
      }
      room:judge(judge)
      player:broadcastSkillInvoke(self.name)
      if judge.card.suit == Card.Spade then
        if i ~= 1 then
          room:loseHp(player, 1, self.name)
        end
        room:addPlayerMark(player,"@kuangdu_time",1)
        local targets = room:askForChooseToMoveCardInBoard(player, "#kuangdu-move", self.name, true, nil)
        if #targets ~= 0 then
          targets = table.map(targets, function(id) return room:getPlayerById(id) end)
          room:askForMoveCardInBoard(player, targets[1], targets[2], self.name)
        end
        break
      end
      if judge.card.suit == Card.Club then
        if i ~= 1 then
          room:loseHp(player, 1, self.name)
        end
        room:addPlayerMark(player,"@kuangdu_time",1)
        local targets = table.filter(room.alive_players, function (p) return not p:isAllNude() end)
        if #targets > 0 then
          local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#kuangdu-throw", self.name, true)
          local to = room:getPlayerById(tos[1])
          local card = room:askForCardChosen(player, to, "hej", self.name)
          room:throwCard(card, self.name, to, player)
        end
        break
      end
      if judge.card.suit == Card.Heart then
        player:setSkillUseHistory("kuangdu", 0, Player.HistoryGame)
        room:recover{
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name
        }
        room:addPlayerMark(player,"@kuangdu_time",1)
        if player.dead or not room:askForSkillInvoke(player, self.name, nil, "#kuajngdu-ask") then
          break
        end
      end
      if judge.card.suit == Card.Diamond then
        room:drawCards(player, 1, self.name)
        player:setSkillUseHistory("kuangdu", 0, Player.HistoryGame)
        room:addPlayerMark(player,"@kuangdu_time",1)
        if player.dead or not room:askForSkillInvoke(player, self.name, nil, "#kuajngdu-ask") then
          break
        end
      end
    end
    room:drawCards(player, player:getMark("@kuangdu_time"), self.name)
    room:setPlayerMark(player,"@kuangdu_time",0)
    if player:getMark("@@lianjin") == 1 then
      room:addPlayerMark(player,"nep-lj-tm",1)
      if player:getMark("nep-lj-tm") == 2 then
        room:handleAddLoseSkills(player,"-hongyan",nil,nil,true)
      end
    end
  end
}
local lianjin = fk.CreateActiveSkill{
  name = "lianjin",
  anim_type = "offensive",
  card_num = 7,
  target_num = 0,
  frequency = Skill.Limited,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  card_filter = function(self, to_select, selected)
    return #selected < 7 and Fk:currentRoom():getCardArea(to_select) == Player.Hand and not Self:prohibitDiscard(Fk:getCardById(to_select))
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local room = player.room
    room:throwCard(effect.cards, self.name, player, player)
    room:setPlayerMark(player,"@@lianjin",1)
    room:handleAddLoseSkills(player,"hongyan",nil,nil,true)
  end,
}

local wangdai = fk.CreateActiveSkill{
  name = "wangdai",
  anim_type = "offensive",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryRound) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local room = player.room
    player:drawCards(2, self.name)
    room:setPlayerMark(player, "@@wangdai_skip", 1)
  end,
}

local wangdai_delay = fk.CreateTriggerSkill{
  name = "#wangdai_delay",
  mute = true,
  events = {fk.EventPhaseChanging},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@@wangdai_skip") > 0 and data.to == Player.Draw
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    player:skip(Player.Draw)
    player.room:setPlayerMark(player, "@@wangdai_skip", 0)
    return true
  end,
}
local lianjin_refresh = fk.CreateTriggerSkill{
  name = "#lianjin_refresh",
  refresh_events = {fk.TurnStart},
  can_refresh = function(self, event, target, player, data)
    if event == fk.TurnStart then
      return target == player and player:getMark("@@lianjin") ~= 0
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TurnStart then
      room:setPlayerMark(player, "@@lianjin", 0)
      room:setPlayerMark(player, "@@lianjin-turn", 1)
    end
  end,
}

Fk:loadTranslationTable{
  ["kuangdu"] = "狂赌",
  [":kuangdu"] = "限定技，当你使用一张牌后，你可以判定：<br>"..
  "红色：可重复此流程<br>"..
  "黑色：失去一点体力<br>"..
  "红桃：视为未发动并回复1点体力<br>"..
  "方片：摸一张牌<br>"..
  "黑桃：移动场上的一张牌<br>"..
  "梅花：弃置一名角色的一张牌<br>"..
  "判定结束后，每判定一次，摸一张牌。当判定结果为黑色时，若此次为第一次判定，则不失去体力。",
  ["@kuangdu_time"] = "判定次数",
  ["@@lianjin"] = "炼金",
  ["@@lianjin-turn"] = "炼金",
  ["lianjin"] = "炼金",
  [":lianjin"] = "限定技，出牌阶段，你可以弃置七张手牌，然后直到你的下个回合的结束阶段，每回合可以无视是否已经发动过【狂赌】使用至多3次【狂赌】，然后你获得【红颜】直到你再发动了两次【狂赌】。",
  ["#kuangdu-throw"] = "弃置场上的一张牌",
  ["#kuangdu-move"] = "移动场上的一张牌",
  ["$kuangdu1"] = "我测试你们的马！",
  ["$kuangdu2"] = "谁家小孩！",
  ["$lianjin1"] = "大香蕉一条大香蕉，你的感觉真的很奇妙~",
  ["$lianjin2"] = "对对对，你说的太对了，我只能说你说的好对啊",
  ["~sk__nep"] = "我操死你们的马...",
  ["@@wangdai_skip"] = "网贷",
  ["wangdai"] = "网贷",
  [":wangdai"] = "出牌阶段限一次，你可以摸两张牌，然后跳过你的下个摸牌阶段。",
  ["$wangdai1"] = "我不要上学~哈哈哎呦 我要玩迷你世界~",
  ["$wangdai2"] = "不是哥们你是没听过我声音吗你需要他给你形容",
  ["#kuajngdu-ask"] = "是否继续判定",
}


sk__nep:addSkill(kuangdu)
lianjin:addRelatedSkill(lianjin_refresh)
sk__nep:addSkill(lianjin)
wangdai:addRelatedSkill(wangdai_delay)
sk__nep:addSkill(wangdai)
















































local sk__xf = General:new(jd, "sk__xf", "skeld", 3, 3,General.Female)


local wangxian = fk.CreateTriggerSkill{
  name = "wangxian",
  anim_type = "defensive",
  events = {fk.TargetConfirming, fk.EventPhaseStart},
  frequency = Skill.Compulsory,
  derived_piles = "wangxian_ping",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or player ~= target then return false end
    if event == fk.TargetConfirming then
      return data.card.trueName ~= "peach" and data.card.trueName ~= "analeptic" and
      not (data.extra_data and data.extra_data.WangxianUse) and
      not data.card:isVirtual() and
      AimGroup:isOnlyTarget(player, data) and #player:getPile("wangxian_ping") < 9999
    elseif event == fk.EventPhaseStart then
      return player.phase == Player.Finish and #player:getPile("wangxian_ping") > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetConfirming then
      data.tos = AimGroup:initAimGroup({})
      data.targetGroup = {}
      if room:getCardArea(data.card) ~= Card.Processing then return true end
      player:addToPile("wangxian_ping", data.card, true, self.name)
      if table.contains(player:getPile("wangxian_ping"), data.card.id) then
        local mark = player:getMark(self.name)
        if type(mark) ~= "table" then mark = {} end
        table.insert(mark, {data.card.id, data.from})
        room:setPlayerMark(player, self.name, mark)
      end
      return true
    elseif event == fk.EventPhaseStart then
      while #player:getPile("wangxian_ping") > 0 do
        local id = player:getPile("wangxian_ping")[1]
        local jy_remove = true
        local card = Fk:getCardById(id)
        local mark = player:getMark(self.name)
        if player:getMark("@delay_ping") > 0 then
          room:addPlayerMark(player,"@delay_ping",-1)
          break
        end
        if type(mark) == "table" then
          local pid
          for _, jy_record in ipairs(mark) do
            if #jy_record == 2 and jy_record[1] == id then
              pid = jy_record[2]
              break
            end
          end
          if pid ~= nil then
            local from = room:getPlayerById(pid)
            if from and not from.dead then
              if from:canUse(card) and not from:prohibitUse(card) and not from:isProhibited(player, card) and
                  (card.skill:modTargetFilter(player.id, {}, from, card, false)) then
                local tos = {{player.id}}
                if card.skill:getMinTargetNum() == 2 then
                  local targets = table.filter(room.alive_players, function (p)
                    return p ~= player and card.skill:targetFilter(p.id, {player.id}, {}, card, nil, from)
                  end)
                  if #targets > 0 then
                    local to_slash = room:askForChoosePlayers(from, table.map(targets, function (p)
                      return p.id
                    end), 1, 1, "#jueyong-choose::"..player.id..":"..card:toLogString(), self.name, false)
                    if #to_slash > 0 then
                      table.insert(tos, to_slash)
                    end
                  end
                end

                if #tos >= card.skill:getMinTargetNum() then
                  jy_remove = false
                  room:useCard({
                    from = pid,
                    tos = tos,
                    card = card,
                    extra_data = {WangxianUse = true}
                  })
                end
              end
            end
          end
        end
        if jy_remove then
          room:moveCards({
            from = player.id,
            ids = {id},
            toArea = Card.DiscardPile,
            moveReason = fk.ReasonPutIntoDiscardPile,
            skillName = self.name,
          })
        end
      end
    end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    return type(player:getMark(self.name)) == "table"
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local pile = player:getPile("wangxian_ping")
    if #pile == 0 then
      room:setPlayerMark(player, self.name, 0)
      return false
    end
    local mark = player:getMark(self.name)
    local to_record = {}
    for _, jy_record in ipairs(mark) do
      if #jy_record == 2 and table.contains(pile, jy_record[1]) then
        table.insert(to_record, jy_record)
      end
    end
    room:setPlayerMark(player, self.name, to_record)
  end,
}


local duanwang = fk.CreateTriggerSkill{
  name = "duanwang",
  anim_type = "offensive",
  events = {fk.AfterSkillEffect},
  can_trigger = function(self, _, target, player, data)
    local slash = Fk:cloneCard 'slash'
    return player:hasSkill(self) and player.phase == Player.NotActive and
      target and target ~= player and
      player.room.logic:getCurrentEvent().n_caduanwang and
      not player:prohibitUse(slash) and
      not player:isProhibited(target, slash)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, data, "#duanwang-invoke::"..target.id)
  end,
  on_use = function(self, _, target, player, data)
    local room = player.room
    local choices = {}
    if player:getMark("@delay_ping") <= 1 then
      table.insert(choices, "delay_ping")
    end
    table.insert(choices, "duanwang_damage")
    local choice = room:askForChoice(player, choices, self.name, "#duanwang-choice::")
    if choice == "delay_ping" then
      room:addPlayerMark(player, "@delay_ping",1)
    else
      local slash = Fk:cloneCard 'slash'
      slash.skillName = self.name
      room:useCard {
        from = player.id,
        tos = { { target.id } },
        card = slash,
        additionalDamage = 0,
      }
    end
  end,

  refresh_events = {fk.AfterSkillEffect},
  can_refresh = function(self, _, target, player, data)
    return player:hasSkill(self) and player.phase == Player.NotActive and
      target and target ~= player and
      target:hasSkill(data) and data.visible and
      not player.room.logic:getCurrentEvent().duanwang_counted
  end,
  on_refresh = function(self, _, target, _, _)
    local room = target.room
    local cur = room.logic:getCurrentEvent()
    cur.duanwang_counted = true
    room:addPlayerMark(target, "@duanwang-turn", 1)
    if (target:getMark("@duanwang-turn") % 3 == 0) then
      cur.n_caduanwang = true
    end
  end,
}

local jiansha = fk.CreateTriggerSkill{
  name = "jiansha",
  mute = true,
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted,fk.Death},
  can_trigger = function(self, event, target, player, data)
    if event == fk.DamageInflicted then
      return target == player and player:hasSkill(self)
    end
    if event == fk.Death then
      return target == player and player:hasSkill(self, false, true) and data.damage and data.damage.from and not data.damage.from.dead
    end
  end,
  on_use = function(self, event, room, player, data)
    if event == fk.DamageInflicted then
      player.room:notifySkillInvoked(player, self.name, "masochism")
      data.from:drawCards(1, self.name)
      player:broadcastSkillInvoke(self.name,1)
    end
    if event == fk.Death then
      local room = player.room
      local to = data.damage.from
      room:handleAddLoseSkills(to, "jiansha", nil)
      player:broadcastSkillInvoke(self.name,2)
    end
  end,
}
local lvshen = fk.CreateActiveSkill{
  name = "lvshen",
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  frequency = Skill.Limited,
  prompt = "#lvshen",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, player.HistoryGame) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return
      #selected == 0 and
      to_select ~= Self.id
  end,
  target_num = 1,
  on_use = function(self, room,effect)
    local player = room:getPlayerById(effect.from)
    player:broadcastSkillInvoke(self.name)
    local target = room:getPlayerById(effect.tos[1])
    for _, p in ipairs(room.alive_players) do
      room:handleAddLoseSkills(p, "-tiangou", nil, true, false)
    end
    room:handleAddLoseSkills(target, "tiangou", nil, true, false)
    local max = target.maxHp - 1
    room:setPlayerMark(target, "@tiangou_son", max)
  end,
}
local tiangou = fk.CreateTriggerSkill{
  name = "tiangou",
  events = {fk.EventPhaseStart},
  frequency = Skill.Compulsory,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    if player:hasSkill(self) and player == target and (not player:isKongcheng()) then
      if event == fk.EventPhaseStart then
        return (player.phase == player.Start or player.phase == player.Finish) and table.find(player.room.alive_players, function (p)
          return p ~= player and p:hasSkill("lvshen", true) end)
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      room:notifySkillInvoked(player, self.name, "negative")
      player:broadcastSkillInvoke(self.name)
      local fathers = table.filter(room.alive_players, function (p) return p ~= player and p:hasSkill("lvshen", true) end)
      if #fathers == 1 then
        room:doIndicate(player.id, {fathers[1].id})
        if player:isKongcheng() then return false end
        local card = room:askForCard(player, 1, 1, false, self.name, false, ".", "#tiangou-give-to:"..fathers[1].id)
        if #card > 0 then
          room:obtainCard(fathers[1].id, card[1], false, fk.ReasonGive)
        end
      else
        local tos, id = room:askForChooseCardAndPlayers(player, table.map(fathers, Util.IdMapper), 1, 1, ".|.|.|hand", "#tiangou-give", self.name, false)
        if #tos > 0 and id then
          room:obtainCard(tos[1], id, false, fk.ReasonGive)
        end
      end
      if player.phase == Player.Finish then
        player.room:addPlayerMark(player, "@tiangou_son", -1)
        if player:getMark("@tiangou_son") == 0 then
          player.room:handleAddLoseSkills(player, "-tiangou", nil, true, false)
        end
      end
    end
  end,
}

Fk:loadTranslationTable{
  ["sk__xf"] = "小粉",
  ["#sk__xf"] = "高PING战士",
  ["designer:sk__xf"] = "塔罗牌", 
  ["cv:sk__xf"] = "AI",
  ["illustrator:sk__xf"] = "小粉",



  ["wangxian"] = "网线",
  [":wangxian"] = "锁定技，当你成为一张非因〖网线〗使用的、非转化且非虚拟的牌（【桃】和【酒】除外）指定的目标时，若你是此牌的唯一目标，"..
  "你取消之。然后将此牌置于你的武将牌上，称为“PING”。结束阶段，若你有“PING”，则按照置入顺序从前到后依次结算“PING”，"..
  "令其原使用者对你使用（若此牌使用者不在场，则将此牌置入弃牌堆）。",
  ["wangxian_ping"] = "PING",
  ["#wangxian-choose"] = "网线：选择对%dest使用的%arg的副目标",
  ["$wangxian1"] = "你们别刷了，我都114514PING了！",
  ["$wangxian2"] = "别刷了，你看我键盘AWSL都按不了了！",


  ["duanwang"] = "断网",
  ["@duanwang-turn"] = "技能次数",
  ["#duanwang-invoke"] = "断网: 你可以选择一项，视为使用【杀】或延迟结算",
  [":duanwang"] = "你的回合外，当其他角色于一回合内每发动3次技能后，" ..
    "你选择一项：1.你视为对其使用了一张【杀】。2.使【网线】结算PING延迟一回合（若已延迟2回合，则只能视为使用【杀】）" ,
  ["@delay_ping"] = "断网",
  ["#duanwang-choice::"] = "选择一项",
  ["$duanwang1"] = "别刷了，别刷了！",
  ["$duanwang2"] = "别刷了，我要制裁你们！",

  ["jiansha"] = "奸杀",
  [":jiansha"] = "锁定技，当你受到伤害时，伤害来源摸一张牌。当你死亡时，杀死你的角色获得【奸杀】。",
  ["$jiansha1"] = "啊！",
  ["$jiansha2"] = "呜呜呜，被奸杀了",

  ["lvshen"] = "吕神",
  [":lvshen"] = "限定技，准备阶段，你可以使一名角色获得【舔狗】标记，持续X回合，有【舔狗】标记的角色获得技能【舔狗】（X为目标体力上限-1）。",
  ["$lvshen"] = "我只是个场外人啊，我不理解你们的矛盾！",


  ["tiangou"] = "舔狗",
  [":tiangou"] = "锁定技，准备阶段和结束阶段，你将一张牌交给拥有技能〖吕神〗的角色。",
  ["@tiangou_son"] = "舔狗",
  ["#tiangou-give-to"] = "舔狗：必须选择一张手牌交给%src",
  ["#tiangou-give"] = "舔狗：必须选择一张牌交给一名拥有吕神的角色",
  ["$tiangou1"] = "小粉，我爱你呀！",

  ["duanwang_damage"] = "视为对其使用杀",
  ["delay_ping"] = "延迟PING结算",
  ["#lvshen"] = "选择一名角色获得【舔狗】",

  ["#duanwang-choice"] = "选择一项"
}

sk__xf:addSkill(wangxian)
sk__xf:addSkill(duanwang)
sk__xf:addSkill(jiansha)
sk__xf:addSkill(lvshen)
sk__xf:addRelatedSkill(tiangou)






































local sk__wk = General:new(jd, "sk__wk", "skeld", 3, 4,General.Male)
sk__wk.shield = 1



local gaohuang = fk.CreateTriggerSkill{
  name = "gaohuang",
  anim_type = "drawcard",
  expand_pile = "gaohuang&",
  derived_piles = "gaohuang&",
  events = {fk.EventPhaseStart, fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    if player:hasSkill(self) then
      if event == fk.EventPhaseStart then
        return target == player and player.phase == Player.Start and not player:isKongcheng() and #player:getPile("gaohuang&") < 4
      else
        for _, move in ipairs(data) do
          if move.from == player.id then
            for _, info in ipairs(move.moveInfo) do
              if info.fromSpecialName == "gaohuang&" and player:usedSkillTimes(self.name, Player.HistoryRound) < 3 then
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      local _, dat = player.room:askForUseActiveSkill(target, "gaohuang_active", "#gaohuang-invoke", true)
      if dat then
        self.cost_data = dat.cards
        return true
      end
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      player:addToPile("gaohuang&", self.cost_data, true, self.name)
    else
      local room = player.room
      local suits = {}
      for _, move in ipairs(data) do
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerSpecial and info.fromSpecialName == "gaohuang&" then
              table.insertIfNeed(suits, Fk:getCardById(info.cardId):getSuitString())
            end
          end
        end
      end
      local mp = #player:getPile("gaohuang&")+1
      if mp >= 3 then
        mp = 3
      end
      room:drawCards(player,mp,self.name,top)
      room:loseHp(player,1,self.name)
    end
  end,
}
local gaohuang_active = fk.CreateActiveSkill{
  name = "gaohuang_active",
  mute = true,
  min_card_num = 0,
  max_card_num = 2,
  target_num = 0,
  card_filter = function(self, to_select, selected)
    if Fk:currentRoom():getCardArea(to_select) == Player.Equip then return end
    if #selected == 0 then
      return true
    else
      return true
    end
  end,
}



local faqing = fk.CreateActiveSkill{
  name = "faqing",
  anim_type = "offensive",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryRound) == 0 and #player:getPile("gaohuang&") < 3
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    player:addToPile("gaohuang&", player:getCardIds(Player.Hand), true, self.name)
    while true do
      if player:isWounded() then
        room:recover{
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name
        }
      else
        break
      end
    end
    room:changeMaxHp(player,-1)
  end,
}



local faqing_dis = fk.CreateDistanceSkill{
  name = "#faqing_dis",
  correct_func = function(self, from, to)
    if from:hasSkill(self) then
      local n = 0
      for _, p in ipairs(Fk:currentRoom().alive_players) do
        if p:isFemale() then
          n = n + 1
        end
      end
      return -n
    end
    return 0
  end,
}



Fk:addSkill(gaohuang_active)
sk__wk:addSkill(gaohuang)
faqing:addRelatedSkill(faqing_dis)
sk__wk:addSkill(faqing)
















Fk:loadTranslationTable{
  ["sk__wk"] = "悟空",
  ["#sk__wk"] = "软色情之王",
  ["designer:sk__wk"] = "塔罗牌", 
  ["cv:sk__wk"] = "AI",
  ["illustrator:sk__wk"] = "悟空",




  ["gaohuang"] = "搞黄",
  [":gaohuang"] = "准备阶段，若你的“黄”数小于4，你可以将至多两张手牌置于武将牌上，称为“黄”，你可以将“黄”如手牌般使用或打出；出牌阶段限两次，当“黄”离开你的武将牌时，"..
  "你失去1点体力并摸X张牌(X为“黄”的数量加1且至多为3）。",
  ["gaohuang&"] = "黄",
  ["gaohuang_active"] = "搞黄",
  ["#gaohuang-invoke"] = "搞黄：你可以将至多两张手牌置为“黄”",
  ["$gaohuang1"] = "小粉，我要奸杀你！",
  ["$gaohuang2"] = "有教培，豪堪",



  ["faqing"] = "发情",
  [":faqing"] = "①出牌阶段限一次，若你的“黄”数小于3，你可以将所有手牌变为“黄”，然后回复所有体力并失去1点体力上限。<br>"..
  "②你计算与其他角色的距离-X（X为女性角色数）。",
  ["$faqing1"] = "不好意思，昨晚打给你了",
  ["$faqing2"] = "我要开导 我要开导 我要开导 我要开导 我要开导",
}




local sk__bot = General:new(jd, "sk__bot", "skeld", 3, 3,General.Male)

local sanpiao = fk.CreateTriggerSkill{
  name = "sanpiao",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.GamePrepared,fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      return event == fk.GamePrepared or
        (target == player and player.phase == Player.Start and player:getMark("sanpiao_mp") ~= 1)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.phase == Player.Start then
      local get = nil
      local shengxi_derivecards = {{"piao", Card.Heart, 7}, {"piao", Card.Diamond, 9},{"piao", Card.Club, 13},{"piao", Card.Spade, 2}, {"piao", Card.Heart, 2},{"piao", Card.Heart, 1}}
      local cards = table.filter(U.prepareDeriveCards(room, shengxi_derivecards, "shengxi_derivecards"), function (id)
        return room:getCardArea(id) == Card.Void
      end)
      if #cards > 0 then
        get = table.random(cards)
      else
        local cids = room:getCardsFromPileByRule("piao")
        if #cids > 0 then get = cids[1] end
      end
      if get then
        if player:getMark("sanpiao_mp") ~= 1 then
          room:obtainCard(player, get, true, fk.ReasonPrey, player.id, self.name, MarkEnum.DestructIntoDiscard)
          player:setMark("sanpiao_mp",1)
        end
      end
    end
  end,
}

local kaihui = fk.CreateActiveSkill{
  name = "kaihui",
  card_num = 1,
  target_num = 0,
  prompt = "#kaihui",
  mute = true,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and not player:isKongcheng()
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    player:chat("会议开始!")
    room:notifySkillInvoked(player, self.name, "offensive")
    player:broadcastSkillInvoke(self.name,1)
    local card = Fk:getCardById(effect.cards[1])
    player:showCards(effect.cards)
    local targets = table.filter(room.alive_players, function(p) return not p:isKongcheng() end)
    room:delay(1000)
    for _, p in ipairs(targets) do
      if p ~= player then
        local show = room:askForCardsChosen(p, p, 1, 1, "h", self.name)
        local gg = p.general
        p.general = "sk__bot"
        player.general = "sk_d_er"
        room:broadcastProperty(p, "general")
        p:showCards(show)
        p:broadcastSkillInvoke(self.name,math.random(2,5))
        p:chat("我是雷雨bot!")
        if table.find(show, function(id) return Fk:getCardById(id).color == card.color end) then
          room:addPlayerMark(player,"kaihui-same",1)
        elseif table.find(show, function(id) return Fk:getCardById(id).color ~= card.color end) then
          room:addPlayerMark(player,"kaihui-diff",1)
        end
        room:delay(1000)
        p.general = gg
        room:broadcastProperty(p, "general")
      end
    end
    if player:getMark("kaihui-same") >= player:getMark("kaihui-diff") then
      player:chat("无需多言!")
      player:broadcastSkillInvoke(self.name,6)
      room:setPlayerMark(player,"kaihui-diff",0)
      while player:getMark("kaihui-same") > 0 do
        card = room:printCard("piao",Card.Heart, 7)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
        room:addPlayerMark(player,"kaihui-same",-1)
      end
    else
      player:chat("丸辣!")
      player:broadcastSkillInvoke(self.name,7)
      local id = table.random(player:getCardIds("h"))
      room:throwCard({id}, self.name, player, player)
      room:setPlayerMark(player,"kaihui-same",0)
      room:setPlayerMark(player,"kaihui-diff",0)
    end
  end
}





sk__bot:addSkill(sanpiao)
sk__bot:addSkill(kaihui)

Fk:loadTranslationTable{
  ["sk__bot"] = "雷雨BOT",
  ["#sk__bot"] = "SKELD创始者",
  ["designer:sk__bot"] = "塔罗牌",
  ["cv:sk__bot"] = "BOT",
  ["illustrator:sk__bot"] = "雷雨BOT",

  ["sanpiao"] = "三票",
  [":sanpiao"] = "锁定技，游戏开始时，你将6张<a href='sanpiao_href'>【票】</a>加入牌堆。每局游戏限一次，准备阶段，你获得一张<a href='sanpiao_href'>【票】</a>。",
  ["kaihui"] = "开会",
  [":kaihui"] = "出牌阶段限一次，你可以展示一张手牌，然后其他所有角色依次展示一张手牌，然后若展示牌与你展示牌的颜色相同的角色大于等于不相同的角色，则每一名相同的角色使你获得一张【票】；否则你随机弃置一张手牌。",
  ["#kaihui"] = "发现尸体！开始投票！",
  ["sanpiao_href"] = "票<br />锦囊牌<br />" ..
  "<b>时机</b>：出牌阶段<br />" ..
  "<b>目标</b>：一名其他角色<br />" ..
  "<b>效果</b>：将此牌置于其武将牌上，若达到三票则其翻面并弃置所有手牌。",

  ["$kaihui1"] = "我根本来不及判断他是个什么东西",
  ["$kaihui2"] = "我是雷雨bot！",
  ["$kaihui3"] = "我也是雷雨bot！",
  ["$kaihui4"] = "我是雷雨bot！",
  ["$kaihui5"] = "我才是雷雨bot！",
  ["$kaihui6"] = "大半夜的大喊大叫会被骂的",
  ["$kaihui7"] = "卧槽卧槽他妈完了",

  ["$sanpiao"] = "小丑这种情况下会开大吗<br>（dbq这句是我随便凑的没语音了）",
}








local sk__cr = General:new(jd, "sk__cr", "skeld", 3, 3,General.Male)
local sk__crxh = General:new(jd, "sk__crxh", "skeld", 3, 3,General.Male)
sk__crxh.total_hidden = true




local zhaqun = fk.CreateTriggerSkill{
  name = "zhaqun",
  anim_type = "control",
  frequency = Skill.Limited,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start and
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player,table.map(room.alive_players, Util.IdMapper),1,1,"#zhaqun-choose",self.name,false)
    to = room:getPlayerById(to[1])
    room:setPlayerMark(player,"zhaqun_yong",1)
    local choices = {"#lose3hp", "#throwCard"}
    local choosed = room:askForChoice(to, choices, self.name, "#zhaqun-ask:", false, choices)
    if choosed == "#lose3hp" then
      room:loseHp(to,3,self.name)
      to:chat("泥马勒戈壁")
    else
      to:throwAllCards("hej")
      to:turnOver()
      to:chat("额啊 解散群聊自保吧")
    end
    room:damage{
      to = player,
      damage = 3,
      damageType = fk.NormalDamage,
      skillName = self.name,
    }
    player:chat("我是超级色图王")
  end,
}

local duigang = fk.CreateActiveSkill{
  name = "duigang",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and Self:canPindian(Fk:currentRoom():getPlayerById(to_select)) and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local pindian = player:pindian({target}, self.name)
    if pindian.results[target.id].winner == player then
      if target:isNude() then return false end
      local to = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1,
      "#duigang-choose:", self.name, false)
      local target1 = room:getPlayerById(to[1])
      local target2 = target
      local card = room:askForCardChosen(target1, target2, "he", self.name)
      room:obtainCard(target1.id, card, false, fk.ReasonPrey)
      player:chat("小小er可笑可笑")
    else
      room:damage{
        from = target,
        to = player,
        damage = 1,
        skillName = self.name,
      }
      player:chat("这仇，我记下了")
    end
  end,
}
local duigang_fw = fk.CreateActiveSkill{
  name = "duigang_fw",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and Self:canPindian(Fk:currentRoom():getPlayerById(to_select)) and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local pindian = player:pindian({target}, self.name)
    room:drawCards(player,2)
    room:drawCards(target,2)
  end,
}
local zhaqun_delay = fk.CreateTriggerSkill{
  name = "#zhaqun_delay",
  events = {fk.AskForPeachesDone},
  frequency = Skill.Compulsory,
  main_skill = zhaqun,
  can_trigger = function(self, event, target, player, data)
    if player:usedSkillTimes(zhaqun, Player.HistoryGame) == 0 and player:getMark("zhaqun_yong") ~= 1 then
      return player:hasSkill(self) and target.hp < 1 and target == player
    elseif player:usedSkillTimes(zhaqun, Player.HistoryGame) == 1 and player:getMark("zhaqun_yong") == 1 then
    end

  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover{
      who = target,
      num = target.maxHp-target.hp,
      recoverBy = player,
      skillName = self.name
    }
    room:handleAddLoseSkills(player, "-zhaqun|-qianfu|-duigang|duigang_fw", nil, true, false)
    if player.general == "sk__cr" then
      player.general = "sk__crxh"
      room:broadcastProperty(player, "general")
      room:setPlayerMark(player,"@zhaqun_xiaohao_count",3)
    end
  end,
}

local zhaqun_double = fk.CreateTriggerSkill{
  name = "#zhaqun_double",
  events = {fk.RoundStart},
  mute = true,
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and event == fk.RoundStart then
      return true
    end
  end,
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      room:addPlayerMark(player,"@zhaqun_xiaohao_count",-1)
      if player:getMark("@zhaqun_xiaohao_count") == 0 then
        room:handleAddLoseSkills(player, "zhaqun|-zhaqun_double", nil, true, false)
        if player.general == "sk__crxh" then
          player.general = "sk__cr"
          room:broadcastProperty(player, "general")
        end
      end
    end
  end,
}


local qianfu = fk.CreateTriggerSkill{
  name = "qianfu",
  mute = true,
  events = {fk.RoundStart,fk.EnterDying,fk.TurnStart},
  frequency = Skill.Quest,
  can_trigger = function(self, event, target, player, data)
    if player:getQuestSkillState(self.name) == nil and player:hasSkill(self) then
      if target == player and event == fk.TurnStart and #player.room.alive_players - 1 <= player.room:getTag("RoundCount") then
        return true
      elseif event == fk.EnterDying and target ~= player and data.damage.from == player then
        return true
      elseif event == fk.RoundStart then
        return true
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TurnStart then
      local room = player.room
      player:drawCards(#player.room.alive_players - 1,self.name)
      room:updateQuestSkillState(player, self.name, false)
      room:notifySkillInvoked(player, self.name, "big")
      room:handleAddLoseSkills(player, "zhaqun|duigang", nil)
      player:chat("我的任务，完成啦！")
    elseif event == fk.RoundStart then
      room:notifySkillInvoked(player, self.name,"support")
      room:changeMaxHp(player,1)
      room:recover{
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      }
    elseif event == fk.EnterDying then
      room:updateQuestSkillState(player, self.name, true)
      room:notifySkillInvoked(player, self.name, "negative")
      local numm = 2 - player.maxHp
      room:changeMaxHp(player,numm)
      room:changeHero(
      player,
      "sk__bot",
      false,
      false,
      false,
      false
      )
      player:chat("我潜伏失败了，我肯定得死，你们也别想活着！")
    end
  end,
}
sk__cr:addSkill(qianfu)
duigang_fw:addRelatedSkill(zhaqun_double)
sk__cr:addRelatedSkill(duigang)
sk__cr:addRelatedSkill(duigang_fw)
zhaqun:addRelatedSkill(zhaqun_delay)
sk__cr:addRelatedSkill(zhaqun)



Fk:loadTranslationTable{
  ["sk__cr"] = "陈睿",
  ["#sk__cr"] = "隐藏的炸群者",
  ["designer:sk__cr"] = "塔罗牌",
  ["cv:sk__cr"] = "无",
  ["illustrator:sk__cr"] = "陈睿",

  ["zhaqun"] = "炸群",
  [":zhaqun"] = "限定技，回合开始时你可以一名角色，你令其选择一项:失去三点体力或弃置所有手牌并翻面然后失去一点体力；然后你对自己造成三点伤害;然后若你以此法即将死亡，你回复所有体力并将武将牌替换为【小号】持续3轮",
  ["#lose3hp"] = "失去3点体力",
  ["#zhaqun-choose"] = "发动【炸群】,选择一名角色，对他造成伤害或使其翻面，但是自己也会受伤",

  ["qianfu"] = "潜伏",
  [":qianfu"] = "使命技，每轮开始时，你增加一点体力上限并回复一点体力"..
  "<br><strong>成功</strong>：准备阶段，若你存活且已是第X轮，你摸X张牌，【潜伏】失效并获得【炸群】【对刚】（X为场上存活人数-1）"..
  "<br><strong>失败</strong>：当你使一名角色进入濒死状态时，你将体力上限调整至2，【潜伏】失效并把武将牌替换为【雷雨bot】",

  ["sk__crxh"] = "小号",
  ["@zhaqun_xiaohao_count"] = "小号回合:",

  ["#throwCard"] = "弃置所有牌并失去1点体力",
  ["#zhaqun-ask:"] = "选择一项",
  ["#zhaqun-choose"] = "选择一个目标",

  ["#zhaqun_delay"] = "炸群",
  ["zhaqun_double"] = "二技能",

  ["duigang"] = "对刚",
  ["#duigang-choose"] = "选择一名角色，获取被拼点角色的一张牌",
  [":duigang"] = "出牌阶段限一次，你可与一名角色拼点，若你赢，你使一名角色获得其一张牌；若你没赢，你受到其造成的1点伤害。",
  [":duigang_fw"] = "出牌阶段限一次，你可与一名角色拼点，然后你与其各摸两张牌。",
  ["duigang_fw"] = "对拼",
}















local sk__bz = General:new(jd, "sk__bz", "skeld", 2, 3,General.Male)
local sk__bz_shen = General:new(jd, "sk__bz_shen", "skeld", 3, 3,General.Male)
local sk__bz_nq = General:new(jd, "sk__bz_nq", "skeld", 3, 3,General.Male)
sk__bz_shen.hidden = true
sk__bz_nq.hidden = true


local ego = fk.CreateTriggerSkill{
  name = "ego",
  mute = true,
  events = {fk.RoundStart,fk.AskForPeachesDone},
  frequency = Skill.Quest,
  can_trigger = function(self, event, target, player, data)
    if event == fk.AskForPeachesDone and player.hp < 1 and player:hasSkill(self) and target == player and player:getQuestSkillState(self.name) ~= "succeed" and player:getQuestSkillState(self.name) ~= "failed" then
      return true
    elseif event == fk.AskForPeachesDone and player.hp >= 1 and player:hasSkill(self) and target == player and player:getQuestSkillState(self.name) ~= "succeed" and player:getQuestSkillState(self.name) ~= "failed" then
      return true
    elseif player:hasSkill(self) and event == fk.RoundStart then
      return true
    end
  end,
  on_cost = Util.TrueFunc(),
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      room:notifySkillInvoked(player, self.name,"support")
      cards = room:askForChoice(player, { "basic", "trick", "equip" }, self.name)
      local cardIds = room:getCardsFromPileByRule(".|.|.|.|.|" .. cards,1)
      if #cardIds > 0 then
        room:obtainCard(player, cardIds[1], true, fk.ReasonPrey)
        room:delay(150)
        player:broadcastSkillInvoke(self.name,3)
      end
      room:loseHp(player,1)
    elseif event == fk.AskForPeachesDone and player.hp < 1 then
      room:notifySkillInvoked(player, self.name,"negative")
      room:updateQuestSkillState(player, self.name, true)
      player:broadcastSkillInvoke(self.name,2)
      room:changeHp(player,999,nil,self.name)
      room:changeHero(
      player,
      "sk__bz_nq",
      true,
      false,
      false,
      false
      )
      room:notifySkillInvoked(player, self.name,"negative")
      room:notifySkillInvoked(player, self.name,"big")
    elseif event == fk.AskForPeachesDone and player.hp >= 1 then
      room:notifySkillInvoked(player, self.name,"defensive")
      room:updateQuestSkillState(player, self.name, false)
      player:broadcastSkillInvoke(self.name,1)
      room:changeHp(player,999,nil,self.name)
      room:changeHero(
      player,
      "sk__bz_shen",
      true,
      false,
      false,
      false
      )
      room:notifySkillInvoked(player, self.name,"support")
      room:notifySkillInvoked(player, self.name,"big")
    end
  end,
}
local ego_prohibit = fk.CreateProhibitSkill{
  name = "#ego_prohibit",
  prohibit_use = function(self, player, card)
    if card.name == "peach" and not player.dying then
      local room = player.room
      return table.find(Fk:currentRoom().alive_players, function(p) return p.dying and p:hasSkill("ego") and p ~= player end)
    end
  end,
}
local ego_prohibit2 = fk.CreateProhibitSkill{
  name = "#ego_prohibit2",
  prohibit_use = function(self, player, card)
    return card and card.name == "peach" and player:hasSkill("ego") and not player.dying
  end,
}
local xuebao = fk.CreateTriggerSkill{
  name = "xuebao",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(self) then return false end
    local card_type = data.card.type
    local room = player.room
    local logic = room.logic
    local use_event = logic:getCurrentEvent()
    local mark_name = "xuebao_" .. data.card:getTypeString() .. "-turn"
    local mark = player:getMark(mark_name)
    local show = ""
    if mark == 0 then
      logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local last_use = e.data[1]
        if last_use.from == player.id and last_use.card.type == card_type then
          mark = e.id
          room:setPlayerMark(player, mark_name, mark)
          return true
        end
        return false
      end, Player.HistoryRound)
    end
    if player:getMark("xuebao_basic-turn") ~= (0 or nil) then
      local a = "基"
      show = show .. a
    end
    if player:getMark("xuebao_trick-turn") ~= (0 or nil) then
      local b = " 锦"
      show = show .. b
    end
    if player:getMark("xuebao_equip-turn") ~= (0 or nil) then
      local c = " 装"
      show = show .. c
    end
    room:setPlayerMark(player, "@xuebao-show-turn", show)
    return mark == use_event.id
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,1)
    room:drawCards(player,1,self.name)
  end,
}

ego:addRelatedSkill(ego_prohibit)
ego:addRelatedSkill(ego_prohibit2)
sk__bz:addSkill(ego)
sk__bz:addSkill(xuebao)


local shenbei = fk.CreateTriggerSkill{
  name = "shenbei",
  events = {fk.RoundStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and event == fk.RoundStart then
      return true
    end
  end,
  on_cost = Util.TrueFunc(),
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      player:broadcastSkillInvoke(self.name)
      room:notifySkillInvoked(player, self.name,"support")
      local targets = table.map(table.filter(U.GetFriends(room, player), function(p)
        return table.every(U.GetFriends(room, player), function(p2)
          return p:isWounded()
        end)
      end), Util.IdMapper)
      if room:isGameMode("role_mode") then
        targets = {player}
      end
      for _, p in ipairs(targets) do
        local pp = room:getPlayerById(p)
        room:recover({
          who = pp,
          num = 1,
          recoverBy = player,
          skillName = self.name
        })
      end
      room:setPlayerMark(player,"@shenbei_time",0)
    end
  end,
}
local shenbei_use = fk.CreateTriggerSkill{
  name = "#shenbei_use",
  anim_type = "offensive",
  events = {fk.AfterCardTargetDeclared},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    local a = 0
    local targets = table.filter(U.GetFriends(room, player), function (p)
      return p:isAlive()
    end)
    for _, p in ipairs(room:getAlivePlayers()) do
      if table.contains(targets, p) and not p.dead then
        a = a + p.hp
      end
    end
    a = math.ceil(a/2)
    if room:isGameMode("role_mode") then
      a = 3
    end
    if target == player and player:hasSkill(self) and data.from == player.id and (not table.contains(player:getTableMark(self.name), data.card.trueName)) and player:getMark("@shenbei_time") < a and data.card.trueName ~= "jink" then
      if (data.card.type == Card.TypeBasic) or (data.card:isCommonTrick()) and data.card.trueName ~= "jink" and data.card.trueName ~= "nullification" then
        return true
      elseif data.card.type == Card.TypeEquip then
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player.room:addTableMark(player, self.name, data.card.trueName)
    player:broadcastSkillInvoke("shenbei",-1)
    if (data.card.type == Card.TypeBasic) or (data.card:isCommonTrick()) then
      local cards = room:askForDiscard(player, 1, 1, true, self.name, true, ".", "#shenbeiu-invoke", true)
      if #cards > 0 then
        local card = Fk:getCardById(cards[1])
        room:throwCard(card,self.name,player,player)
        data.additionalEffect = 1
        room:addPlayerMark(player,"@shenbei_time",1)
      end
    else
      room:drawCards(player,1,self.name)
      room:addPlayerMark(player,"@shenbei_time",1)
    end
  end,
}
local xuebao_ex = fk.CreateTriggerSkill{
  name = "xuebao_ex",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished},
  can_trigger = function(self, room, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,1)
    if target ~= player or not player:hasSkill(self) then return false end
    local card_type = data.card.type
    local room = player.room
    local logic = room.logic
    local use_event = logic:getCurrentEvent()
    local mark_name = "xuebao_" .. data.card:getTypeString() .. "-turn"
    local mark = player:getMark(mark_name)
    local show = ""
    if mark == 0 then
      logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local last_use = e.data[1]
        if last_use.from == player.id and last_use.card.type == card_type then
          mark = e.id
          room:setPlayerMark(player, mark_name, mark)
          return true
        end
        return false
      end, Player.HistoryRound)
    end
    if player:getMark("xuebao_basic-turn") ~= (0 or nil) then
      local a = "基"
      show = show .. a
    end
    if player:getMark("xuebao_trick-turn") ~= (0 or nil) then
      local b = " 锦"
      show = show .. b
    end
    if player:getMark("xuebao_equip-turn") ~= (0 or nil) then
      local c = " 装"
      show = show .. c
    end
    room:setPlayerMark(player, "@xuebao-show-turn", show)
    return mark == use_event.id
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,1)
    local targets = table.filter(U.GetFriends(room, player), function (p)
      return p:isAlive()
    end)
    room:doIndicate(player.id, table.map(targets, Util.IdMapper))
    for _, p in ipairs(room:getAlivePlayers()) do
      if table.contains(targets, p) and not p.dead then
        p:drawCards(1, self.name)
      end
    end

  end,
}
shenbei.permanent_skill = true

shenbei:addRelatedSkill(shenbei_use)
sk__bz_shen:addSkill(shenbei)
sk__bz_shen:addSkill(xuebao_ex)










local niuqu = fk.CreateTriggerSkill{
  name = "niuqu",
  events = {fk.RoundStart,fk.TurnStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if event == fk.RoundStart then
        return true
      elseif target == player and event == fk.TurnStart then
        return true
      end
    end
  end,
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      player:broadcastSkillInvoke(self.name)
      room:notifySkillInvoked(player, self.name,"negative")
      local cardIds = room:getCardsFromPileByRule(".|.|.|.|.|" ,3)
      if #cardIds > 0 then
        room:obtainCard(player, cardIds[1], false, fk.ReasonPrey,player.id,self.name,{"@@niuqu_card-inarea",1})
        room:delay(150)
        room:obtainCard(player, cardIds[2], false, fk.ReasonPrey,player.id,self.name,{"@@niuqu_card-inarea",1})
        room:delay(150)
        room:obtainCard(player, cardIds[3], false, fk.ReasonPrey,player.id,self.name,{"@@niuqu_card-inarea",1})
        room:delay(150)
        player:broadcastSkillInvoke(self.name,3)
      end
    end
    if event == fk.TurnStart then
      player:broadcastSkillInvoke(self.name)
      room:notifySkillInvoked(player, self.name,"negative")
      local cardIds = room:getCardsFromPileByRule(".|.|.|.|.|" ,3)
      if #cardIds > 0 then
        room:obtainCard(player, cardIds[1], false, fk.ReasonPrey,player.id,self.name,{"@@niuqu_card-inarea",1})
        room:delay(150)
        room:obtainCard(player, cardIds[2], false, fk.ReasonPrey,player.id,self.name,{"@@niuqu_card-inarea",1})
        room:delay(150)
        room:obtainCard(player, cardIds[3], false, fk.ReasonPrey,player.id,self.name,{"@@niuqu_card-inarea",1})
        room:delay(150)
        player:broadcastSkillInvoke(self.name,3)
      end
    end
  end,
}
local niuqu_skip = fk.CreateTriggerSkill{
  name = "#niuqu_skip",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseChanging},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.to == Player.Judge
  end,
  on_use = function (self, event, target, player, data)
    if data.to == Player.Judge then
      player:skip(Player.Judge)
      player:skip(Player.Draw)
    end
    return true
  end,
}
local niuqu_use = fk.CreateTriggerSkill{
  name = "#niuqu_use",
  anim_type = "offensive",
  events = {fk.AfterCardTargetDeclared},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and data.from == player.id then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player.room:addTableMark(player, self.name, data.card.trueName)
    player:broadcastSkillInvoke("niuqu",-1)
    if (data.card.number == 1 or data.card.number > 10) or (data.card:getMark("@@niuqu_card-inarea") > 0) then
      local choices = {}
      local allChoices = {"#recover","#disresponsive"}
      if player:getMark("niuqu_choice") ~= 1 then
        table.insert(choices,"#recover")
      end
      if player:getMark("niuqu_choice") ~= 2 then
        table.insert(choices,"#disresponsive")
      end
      local choosed = room:askForChoice(player, choices, self.name, "#niuqu-ask:", false, allChoices)
      if choosed == "#recover" then
        room:recover({
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name
        })
        room:setPlayerMark(player,"niuqu_choice",1)
      elseif choosed == "#disresponsive" then
        local targets = player.room:getOtherPlayers(player)
        if #targets > 0 then
          data.disresponsiveList = data.disresponsiveList or {}
          for _, p in ipairs(targets) do
            table.insertIfNeed(data.disresponsiveList, p.id)
          end
        end
        room:setPlayerMark(player,"niuqu_choice",2)
      else
        room:setPlayerMark(player,"niuqu_choice",0)
      end
    else
      room:loseHp(player,1,self.name)
    end
  end,
}
local xuebao_nq = fk.CreateTriggerSkill{
  name = "xuebao_nq",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished},
  can_trigger = function(self, room, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,1)
    if not player:hasSkill(self) then return false end
    local card_type = data.card.type
    local room = target.room
    local logic = room.logic
    local use_event = logic:getCurrentEvent()
    local mark_name = "xuebao_" .. data.card:getTypeString() .. "-turn"
    local mark = target:getMark(mark_name)
    local show = ""
    if mark == 0 then
      logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local last_use = e.data[1]
        if last_use.from == target.id and last_use.card.type == card_type then
          mark = e.id
          room:setPlayerMark(target, mark_name, mark)
          return true
        end
        return false
      end, Player.HistoryRound)
    end
    if target:getMark("xuebao_basic-turn") ~= (0 or nil) then
      local a = "基"
      show = show .. a
    end
    if target:getMark("xuebao_trick-turn") ~= (0 or nil) then
      local b = " 锦"
      show = show .. b
    end
    if target:getMark("xuebao_equip-turn") ~= (0 or nil) then
      local c = " 装"
      show = show .. c
    end
    room:setPlayerMark(target, "@baoxue-show-turn", show)
    return mark == use_event.id
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,1)
    local id = table.random(target:getCardIds("he"))
    room:throwCard({id}, self.name,target, target)

  end,
}
local niuqu_card = fk.CreateMaxCardsSkill{
  name = "#niuqu_card",
  correct_func = function(self, player)
    if player:hasSkill(self) then
      return -player.hp
    end
  end,
}
niuqu.permanent_skill = true

niuqu:addRelatedSkill(niuqu_use)
niuqu:addRelatedSkill(niuqu_skip)
niuqu:addRelatedSkill(niuqu_card)
sk__bz_nq:addSkill(niuqu)
sk__bz_nq:addSkill(xuebao_nq)

Fk:loadTranslationTable{
  ["sk__bz"] = "北泽",
  ["#sk__bz"] = "快乐的小黄花",
  ["designer:sk__bz"] = "塔罗牌",
  ["cv:sk__bz"] = "北泽",
  ["illustrator:sk__bz"] = "北泽",

  ["ego"] = "E.G.O",
  [":ego"] = "使命技，每轮开始时，你选择一种类型的牌获得1张并失去1点体力。当你处于濒死状态时，其他角色无法对你使用桃，若你不处于濒死状态，你无法使用桃"..
  "<br><strong>成功</strong>：当你脱离濒死状态时，回复所有体力并展现<a href='herf_sk__bz_shen'>神备ego</a>"..
  "<br><strong>失败</strong>：当你即将死亡时，回复所有体力并展现<a href='herf_sk__bz_nq'>扭曲ego</a>",
  ["#ego_prohibit2"] = "E.G.O",
  ["$ego1"] = "额啊，来吧走起！",
  ["$ego2"] = "我复活辣！",
  ["$ego3"] = "兄弟，有偷子",

  ["xuebao"] = "雪豹",
  [":xuebao"] = "锁定技，每名角色的回合每种牌型限一次，当你打出或使用牌时，摸一张牌",
  ["@xuebao-show-turn"] = "雪豹",
  ["$xuebao"] = "雪豹，我们上！",

  ["sk__bz_shen"] = "北泽",
  ["herf_sk__bz_shen"] = "神备E.G.O：<br><b>神备</b>：" ..
  "持恒技，每轮开始时，你使所有友方角色回复1点体力。每回合限X次，当你使用牌时，若此牌牌名未被记录过且类型为：基本牌和普通锦囊牌：此牌结算两次；装备牌：使用时摸一张牌，最后记录此牌名（X为你与友方角色的体力之合减半，向上取整）<br>" ..
  "<b>雪豹</b>：锁定技，每名角色的回合每种牌型限一次，当你打出或使用牌时，你与友方角色摸一张牌",

  ["shenbei"] = "神备",
  [":shenbei"] = "持恒技，每轮开始时，你使所有友方角色回复1点体力。每回合限X次，当你使用牌时，若此牌牌名未被记录过且类型为：基本牌和普通锦囊牌：此牌结算两次；装备牌：使用时摸一张牌，最后记录此牌名（X为你与友方角色的体力之合减半，向上取整）"..
  "<br><font color='red'>村：很抱歉但是：若为身份模式，所有友方角色改为自身,X等于3",
  ["#shenbei_use"] = "神备",
  ["#shenbeiu-invoke"] = "你可以弃置一张手牌，然后此牌可以结算两次",
  ["#shenbei-ask"] = "发动神备，使此牌结算两次，若为装备牌则改为摸一张牌",
  ["$shenbei"] = "啦啦啦，我是一朵快乐的小黄花",
  ["@shenbei_time"] = "神备次数:",

  ["xuebao_ex"] = "雪豹",
  [":xuebao_ex"] = "锁定技，每名角色的回合每种牌型限一次，当你打出或使用牌时，你与友方角色摸一张牌",
  ["$xuebao_ex"] = "雪豹，我们上！",

  ["sk__bz_nq"] = "泽北",
  ["herf_sk__bz_nq"] = "扭曲E.G.O：<br><b>扭曲</b>：" ..
  "持恒技，锁定技，每轮开始时和出牌阶段开始时，你从牌堆中随机获得三张牌，以此法获得的牌成为【扭曲之牌】，你始终跳过摸牌阶段与判定阶段，你的手牌上限始终为0。当你使用牌时，若此牌点数为字母或为【扭曲之牌】，则你选择一项：1.回复1点体力 2.此牌不可被响应。你不能选择上次选择过的选项；否则你失去1点体力。<br>" ..
  "<b>豹雪</b>：锁定技，每名角色的回合每种牌型限一次，除你之外的一名角色角色使用或打出牌后，其随机弃置一张牌。",

  ["niuqu"] = "扭曲",
  [":niuqu"] = "持恒技，锁定技，每轮开始时和出牌阶段开始时，你从牌堆中随机获得三张牌，以此法获得的牌成为【扭曲之牌】，你始终跳过摸牌阶段与判定阶段，你的手牌上限始终为0。当你使用牌时，若此牌点数为字母或为【扭曲之牌】，则你选择一项：1.回复1点体力 2.此牌不可被响应。你不能选择上次选择过的选项；否则你失去1点体力。",
  ["@@niuqu_card-inarea"] = "扭曲之牌",
  ["@niuqu_card"] = "扭曲",
  ["#niuqu_use"] = "扭曲之力",
  ["#recover"] = "回复1点体力",
  ["#disresponsive"] = "此牌不可被响应",
  ["#niuqu-ask:"] = "请选择一项",
  ["$niuqu"] = "（*扭曲的）兄弟 有偷子",

  ["xuebao_nq"] = "豹雪",
  ["@baoxue-show-turn"] = "豹雪",
  [":xuebao_nq"] = "锁定技，每名角色的回合每种牌型限一次，一名角色角色使用或打出牌后，其随机弃置一张牌。",
  ["$xuebao_nq"] = "（*扭曲的）雪豹，我们上",
}




local yeniu = fk.CreateWeapon{
  name = "yeniu",
  suit = Card.Spade,
  number = 10,
  attack_range = 7,
  equip_skill = yeniuSkill,
}

local sk__cha_show = General(jd, "sk__cha_show", "skeld", 1)
sk__cha_show.fixMaxHp = 1
sk__cha_show.total_hidden = true
local cha_yinni = fk.CreateTriggerSkill{
  name = "cha_yinni",
  priority = 0.001,
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.HpChanged, fk.TurnStart, fk.BeforeMaxHpChanged},
  can_trigger = function(self, event, target, player, data)
    if target == player and not player.dead and player:hasSkill(self) and event == fk.HpChanged then
      local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn)
      if turn_event == nil then return end
      local to = turn_event.data[1]
      if to ~= player and not to.dead and not to:isNude() then
        self.cost_data = to
      end
      return true
    elseif target == player and not player.dead and event == fk.TurnStart and player:hasSkill(self) then
      return true
    elseif event == fk.BeforeMaxHpChanged and target == player and not player.dead and player:hasSkill(self) then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.BeforeMaxHpChanged then
      return true
    elseif event == fk.HpChanged then
      for _, p in ipairs(room:getOtherPlayers(player)) do
        if not p.dead then
          p:chat("猹诶")
        end
      end
      room:doIndicate(player.id, {self.cost_data.id})
      local id = room:askForCardChosen(player, self.cost_data, "he", self.name)
      room:moveCardTo(id, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, false, player.id)
      if room:getCardArea(U.prepareDeriveCards(room, {{"yeniu", Card.Spade, 10}}, "chaei_spell")[1]) == Card.Void and
      player:hasEmptyEquipSlot(Card.SubtypeArmor) then
        local spell = U.prepareDeriveCards(room, {{"yeniu", Card.Spade, 10}}, "chaei_spell")[1]
        room:setCardMark(Fk:getCardById(spell), MarkEnum.DestructOutEquip, 1)
        room:moveCardIntoEquip(player, spell, self.name, true, player)
      end
      room:changeHero(
      player,
      "sk__cha",
      false,
      false,
      false,
      true
      )
      room:changeHp(player,player:getMark("cha_hp"),nil,self.name)
      room:setPlayerMark(player,"cha_hp",0)
    elseif event == fk.TurnStart then
      room:changeHero(
      player,
      "sk__cha",
      false,
      false,
      false,
      true
      )
      if room:getCardArea(U.prepareDeriveCards(room, {{"yeniu", Card.Spade, 10}}, "chaei_spell")[1]) == Card.Void and
      player:hasEmptyEquipSlot(Card.SubtypeArmor) then
        local spell = U.prepareDeriveCards(room, {{"yeniu", Card.Spade, 10}}, "chaei_spell")[1]
        room:setCardMark(Fk:getCardById(spell), MarkEnum.DestructOutEquip, 1)
        room:moveCardIntoEquip(player, spell, self.name, true, player)
      end
      local a = player:getMark("cha_hp")-1
      room:changeHp(player,a,nil,self.name)
      room:setPlayerMark(player,"cha_hp",0)
    end
  end,
}
sk__cha_show:addSkill(cha_yinni)

Fk:loadTranslationTable{
  ["sk__cha_show"] = "隐匿的猹",
  ["#sk__cha_show"] = "差误kisu",
  ["designer:sk__cha_show"] = "塔罗牌",
  ["cv:sk__cha"] = "猹",
  ["illustrator:sk__cha_show"] = "猹",

  ["cha_yinni"] = "隐匿",
  [":cha_yinni"] = "隐匿，当你于其他角色的回合登场时，其他所有角色需说一句“猹诶”，然后你获取当前回合角色一张牌。若此次为你首次发动此技能，你从游戏外获得一张【野牛】",
}

local sk__cha = General:new(jd, "sk__cha", "skeld", 3, 3,General.Male)

local chaei = fk.CreateTriggerSkill{
  name = "chaei",
  priority = 0.001,
  events = {fk.GamePrepared},
  anim_type = "control",
  frequency = Skill.Compulsory,
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self)
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"cha_hp",player.hp)
    room:changeHero(
    player,
    "sk__cha_show",
    true,
    false,
    false,
    true
    )
  end,
}


local c_aowu_x = fk.CreateActiveSkill{
  name = "c_aowu_x",
  anim_type = "drawcard",
  prompt = "#c_aowu_x",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1 and player:hasSkill(self.name)
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local allChoices = {"jia","jian"}
    local choices = {"jia"}
    if player:getMaxCards() ~= 0 then
      table.insert(choices,"jian")
    end
    local choice = room:askForChoice(player,choices,self.name,"#c_aowu_ask",false,allChoices)
    if choice == "jian" then
      room:notifySkillInvoked(player, self.name,"negative")
      room:addPlayerMark(player, MarkEnum.MinusMaxCards, 1)
      room:setPlayerMark(player,"@@c_aowu_z",1)
    end
    if choice == "jia" then
      room:notifySkillInvoked(player, self.name,"support")
      room:addPlayerMark(player, MarkEnum.AddMaxCards, 1)
    end
    if player:getMaxCards() == player:getHandcardNum() then
      player:setSkillUseHistory("c_aowu_x", 0, Player.HistoryPhase)
    end
  end,
}


local c_aowu_y = fk.CreateTriggerSkill{
  name = "#c_aowu_y",
  anim_type = "defensive",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish and player:getMaxCards() == 4
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"cha_hp",player.hp)
    room:changeHero(
      player,
      "sk__cha_show",
      true,
      false,
      false,
      true
      )
  end,
}

local c_aowu_z = fk.CreateTriggerSkill{
  name = "#c_aowu_z",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished},
  can_trigger = function(self, room, target, player, data)
    local room = player.room
    if player:hasSkill(self) and target == player and player:getMark("@@c_aowu_z") == 1 then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,1)
    card = room:getCardsFromPileByRule(data.card.trueName)
    if #card == 0 then
      player:drawCards(1, self.name)
    else
      room:moveCards({
        ids = card,
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonJustMove,
        proposer = player.id,
        skillName = self.name,
      })
    end
    room:setPlayerMark(player,"@@c_aowu_z",0)
  end,
}

c_aowu_x:addRelatedSkill(c_aowu_z)
c_aowu_x:addRelatedSkill(c_aowu_y)
sk__cha:addSkill(c_aowu_x)

sk__cha:addSkill(chaei)
sk__cha:addRelatedSkill(cha_yinni)

Fk:loadTranslationTable{
  ["sk__cha"] = "猹",
  ["#sk__cha"] = "差误kisu",
  ["designer:sk__cha"] = "塔罗牌",
  ["cv:sk__cha"] = "猹",
  ["illustrator:sk__cha"] = "猹",

  ["chaei"] = "猹诶",
  [":chaei"] = "隐匿，当你于其他角色的回合登场时，其他所有角色需说一句“猹诶”，然后你获取当前回合角色一张牌。若此次为你首次发动此技能，你从游戏外获得一张【野牛】置入装备区，当以此法获得的【野牛】离开装备区时，销毁其。",
  ["#chaei-AskForSkill"] = "是否发动【猹诶】获取其的一张牌",
  ["$chaei"] = "哈喽",
  ["$cha_yinni"] = "哈喽",

  ["c_aowu_x"] = "嗷呜",
  [":c_aowu_x"] = "①出牌阶段限一次，你可以选择一项：1.减少1点手牌上限，然后你使用下一张牌后从牌堆中获得一张同名牌（若无则改为摸一张牌） 2.增加1点手牌上限。然后若此时你的手牌数等于手牌上限，此技能视为未发动过<br>"..
  "②锁定技，结束阶段，若你的手牌数为4，你视为未发动过【猹诶】",
  ["#c_aowu_x"] = "嗷呜：选择增加或者减少手牌上限，上限和手牌数相等可以重复使用",
  ["#c_aowu_ask"] = "选择一项",
  ["$c_aowu_x1"] = "我是雷雨bot",
  ["$c_aowu_x2"] = "我是你太太",

  ["@@c_aowu_z"] = "嗷呜 牌堆拿牌",
  ["#c_aowu_z"] = "嗷呜",

  ["jia"] = "手牌上限加一",
  ["jian"] = "手牌上限减一",

  ["c_aowu_x"] = "嗷呜",
  ["c_aowu_y"] = "嗷呜",
  ["#c_aowu_y"] = "嗷呜",
}



































local sk__mj = General:new(jd, "sk__mj", "skeld", 3, 3,General.Female)


local biantai = fk.CreateTriggerSkill{
  name = "biantai",
  mute = true,
  events = {fk.DamageInflicted},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryRound) < 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local a = 0
    if data.to == player or data.to == player.id then
      player:broadcastSkillInvoke(self.name,1)
    else
      player:broadcastSkillInvoke(self.name,2)
    end

    if data.to:isMale() then
      a = 1
    end
    player:drawCards(a+1,self.name)
    room:notifySkillInvoked(player, self.name,"drawcard")
  end,
}

local xiadan = fk.CreateTriggerSkill{
  name = "xiadan",
  switch_skill_name = "xiadan",
  anim_type = "switch",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    if event == fk.TargetSpecifying then
      return target == player and player:hasSkill(self)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetSpecifying then
      if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
        player:chat("$!Shoe:"..data.to)
        player:addToPile("mj-dan", data.card, true, self.name)
      end
      if player:getSwitchSkillState(self.name, true) == fk.SwitchYin then
        player:chat("$!GiantEgg:"..data.to)
      end
      return true
    end
  end,
}





local fudan = fk.CreateActiveSkill{
  name = "fudan",
  anim_type = "support",
  card_num = 0,
  derived_piles = "mj-dan",
  prompt = function(self)
    return "#fudan-active:::"..#Self:getPile("mj-dan")
  end,
  min_target_num = 1,
  max_target_num = function(self)
    return #Self:getPile("mj-dan")
  end,
  card_filter = Util.FalseFunc,
  target_filter = function (self, to_select, selected)
    return #selected <= #Self:getPile("mj-dan")
  end,


  can_use = function(self, player)
    return #player:getPile("mj-dan") > 0 and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,

  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local targets = table.simpleClone(effect.tos)
    room:sortPlayersByAction(targets)
    local tos = {}
    for _, id in ipairs(targets) do
      local target = room:getPlayerById(id)
      table.insert(tos, target)
    end
    tos = table.filter(tos, function (p)
      return not p.dead
    end)
    room:useVirtualCard("god_salvation", nil, player, tos, self.name)
    for _, p in ipairs(room.alive_players) do
      if not table.contains(tos,p.id) then
        player:chat("$!GiantEgg:"..p.id)
      end
    end
    if #player:getPile("mj-dan") > 0 then
      room:moveCards({
        from = player.id,
        ids = player:getPile("mj-dan"),
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonPutIntoDiscardPile,
        skillName = self.name,
        fromSpecialName = "mj-dan",
      })
      if player.dead then return false end
    end
  end,
}

local fudan_x = fk.CreateTriggerSkill{
  name = "#fudan_x",
  events = {fk.AfterCardsMove},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      local x, y = player:getMark("fudan_x1_record-round"), player:getMark("fudan_x2_record-round")
      local room = player.room
      local move__event = room.logic:getCurrentEvent()
      local turn_event = move__event:findParent(GameEvent.Turn)
      if turn_event == nil then return false end
      if not move__event or (x > 0 and x ~= move__event.id and y > 0 and y ~= move__event.id) then return false end
      local fudan1_search, fudan2_search = false, false
      for _, move in ipairs(data) do
        if move.toArea == Card.PlayerSpecial then
          if x == 0 then
            for _, info in ipairs(move.moveInfo) do
              if info.fromArea ~= Card.PlayerSpecial then
                fudan1_search = true
              end
            end
          end
        elseif y == 0 then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerSpecial then
              fudan2_search = true
            end
          end
        end
      end
      if fudan1_search or fudan2_search then
        room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
          local moves = e.data
          for _, move in ipairs(moves) do
            if move.toArea == Card.PlayerSpecial then
              if fudan1_search then
                for _, info in ipairs(move.moveInfo) do
                  if info.fromArea ~= Card.PlayerSpecial then
                    x = e.id
                    room:setPlayerMark(player, "fudan_x1_record-round", x)
                    fudan1_search = false
                  end
                end
              end
            elseif fudan2_search then
              for _, info in ipairs(move.moveInfo) do
                if info.fromArea == Card.PlayerSpecial then
                  y = e.id
                  room:setPlayerMark(player, "fudan_x2_record-round", y)
                  fudan2_search = false
                end
              end
            end
            if not (fudan1_search or fudan2_search) then return true end
          end
          return false
        end, Player.HistoryTurn)
      end
      return x == move__event.id or y == move__event.id
    end
  end,
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    local x, y = player:getMark("fudan_x1_record-round"), player:getMark("fudan_x2_record-round")
    local move__event = room.logic:getCurrentEvent()
    if x == move__event.id then
      self.cost_data = "drawcard"
      self:doCost(event, target, player, data)
    end
    if y == move__event.id and player:hasSkill(self) and not player:isNude() then
      self.cost_data = "drawcard"
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local choice = self.cost_data
    local targets = table.filter(player.room.alive_players, function (p)
      return p ~= player and (choice == "drawcard" or not p:isNude())
    end)
    local to = player.room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#fudan_x-" .. choice, self.name, true)
    if #to > 0 then
      self.cost_data = {to[1], choice}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tar = room:getPlayerById(self.cost_data[1])
    local choice = self.cost_data[2]
    if choice == "drawcard" then
      room:notifySkillInvoked(player, self.name, "support")
      player:broadcastSkillInvoke(self.name)
      room:drawCards(player, 1, self.name)
      if not tar.dead then
        room:drawCards(tar, 1, self.name)
      end
    end
    if player.dead then return false end
  end,
}



sk__mj:addSkill(biantai)
sk__mj:addSkill(xiadan)
fudan:addRelatedSkill(fudan_x)
sk__mj:addSkill(fudan)




Fk:loadTranslationTable{
  ["sk__mj"] = "母鸡",
  ["#sk__mj"] = "咯咯哒",
  ["designer:sk__mj"] = "塔罗牌",
  ["cv:sk__mj"] = "母鸡",
  ["illustrator:sk__mj"] = "母鸡",

  ["~sk__mj"] = "我恨你呜呜呜呜呜呜",



  ["biantai"] = "变态",
  [":biantai"] = "锁定技，每轮限一次，一名角色受到伤害时，你摸一张牌，若其为男性角色，摸牌数加1",
  ["$biantai1"] = "我恨你呜呜呜呜呜呜",
  ["$biantai2"] = "我乃幽夜净土的主人，断罪之皇女——菲谢尔，裁断此世一切罪恶，透彻此间一切真知",



  ["xiadan"] = "下蛋",
  [":xiadan"] = "锁定技，转换技，当你使用牌指定一名目标时：阳：你对目标砸拖鞋，然后将此牌置于你的武将牌上称为【蛋】；阴：你对目标砸大蛋"..
  "<br><font color='red'>村：万箭齐发等多目标卡牌指定每一个目标时都会进行转换技切换 即为指定两名目标时会对第一个人砸拖鞋，第二个人大蛋，以此类推",
  ["mj-dan"] = "蛋",
  ["$xiadan1"] = "我啄死你~",
  ["$xiadan2"] = "咯咯咯咯咯咯咯",


  ["fudan"] = "孵蛋",
  [":fudan"] = "①出牌阶段限一次，你可以选择至多X名角色，视为对这些角色使用一张【桃园结义】，然后对未选择的角色砸大蛋，最后移除所有【蛋】（X为你拥有的【蛋】的数量）<br>"..
  "②每轮每项限一次，当一张牌加入/移入游戏时，你可以与一名其他角色各摸一张牌",
  ["#fudan-active"] = "发动孵蛋，对至多 %arg 名角色使用【桃园结义】，然后移除所有【蛋】",
  ["#fudan_x-drawcard"] = "发动孵蛋：你可以和一名其他角色各摸一张牌",
  ["#fudan"] = "孵蛋",
  ["#fudan_x"] = "孵蛋",
  ["$fudan1"] = "这就是你们在CSTWO里对猹痛下杀手的后果!",
  ["$fudan2"] = "看吧，他急了",


}
















local sk__mn = General:new(jd, "sk__mn", "skeld", 4, 4,General.Male)

local zonghuo_x = fk.CreateActiveSkill{
  name = "zonghuo_x",
  anim_type = "defensive",
  card_num = 0,
  target_num = 1,
  prompt = function(self)
    local a = 0
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      a = a + 1
    end
    local b = 0
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:getMark("@@mn_yhw") ~= 0 then
        b = b + 1
      end
    end
    local c = a - b
    if c == 0 then
      return "#zonghuo-b-active"
    else
      return "#zonghuo-a-active:::"..c
    end

  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local room = player.room
    local a = 0
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      a = a + 1
    end
    local b = 0
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:getMark("@@mn_yhw") ~= 0 then
        b = b + 1
      end
    end
    local c = a - b
    if c > 0 then
      local ids = room:askForDiscard(player, c, c, true, self.name, true,
      ".", "#zonghuo-throw-ask:::"..c, false)
    else
      player:drawCards(2, self.name)
    end
    room:damage({
      from = room:getPlayerById(effect.from),
      to = room:getPlayerById(effect.tos[1]),
      damage = 1,
      damageType = fk.FireDamage,
      skillName = self.name
    })
    return false
  end,
}
local zonghuo_y = fk.CreateTriggerSkill{
  name = "#zonghuo_y",
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted},
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return data.damageType == fk.FireDamage and player:hasSkill(self.name)
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    if not data.to.chained then
      data.to:setChainState(true)
    end
    local p1 = data.to:getLastAlive(true, 1)
    player:getLastAlive(true, 1)
    local p2 = data.to:getLastAlive(true, -1)
    room:notifySkillInvoked(player, self.name, "support")
    player:broadcastSkillInvoke(self.name,1)
    if p1:getMark("@@mn_yhw") ~= 1 then
      room:setPlayerMark(p1,"@@mn_yhw",1)
      room:notifySkillInvoked(p1, self.name, "control")
    end
    if p2:getMark("@@mn_yhw") ~= 1 then
      room:setPlayerMark(p2,"@@mn_yhw",1)
      room:notifySkillInvoked(p2, self.name, "control")
    end
  end,
}


local zonghuo_z = fk.CreateTriggerSkill{
  name = "#zonghuo_z",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.RoundStart},
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(zonghuo_x)
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(U.GetFriends(room, player), function(p)
      return table.every(U.GetFriends(room, player), function(p2)
        return p:isAlive()
      end)
    end), Util.IdMapper)
    if room:isGameMode("role_mode") then
      targets = {player.id}
    end
    for _, p in ipairs(targets) do
      local pp = room:getPlayerById(p)
      if not pp.chained then
        pp:setChainState(true)
      end
      room:setPlayerMark(pp,"@@mn_yhw",1)
    end
    player:broadcastSkillInvoke("zonghuo_x",2)
  end,
}

local zifen = fk.CreateActiveSkill{
  name = "zifen",
  anim_type = "big",
  card_num = 0,
  target_num = 0,
  prompt = function(self)
    return "#zifen-active"
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryGame) < 1
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local room = player.room
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:getMark("@@mn_yhw") ~= 0 then
        room:damage({
          from = player,
          to = p,
          damage = 1,
          damageType = fk.NormalDamage,
          skillName = self.name
        })
        if p ~= player then
          room:loseHp(player,1,self.name)
        end
        room:delay(300)
      end
    end
    return false
  end,
}



local fengjin = fk.CreateTriggerSkill{
  name = "fengjin",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.Damage},
  can_trigger = function (self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(U.GetFriends(room, player), function(p)
      return table.every(U.GetFriends(room, player), function(p2)
        return p:isAlive()
      end)
    end), Util.IdMapper)
    if room:isGameMode("role_mode") then
      targets = {player}
    end
    if table.contains(targets,data.to.id) then
      if target == player and player:hasSkill(self.name) then
        return true
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player,"@mn_fengjin",data.damage)
    local mark = player:getMark("@mn_fengjin")
    if mark < 7 then
      room:notifySkillInvoked(player, self.name, "support")
      player:broadcastSkillInvoke(self.name,1)
      room:recover{
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      }
      player:drawCards(1,self.name)
    else
      room:notifySkillInvoked(player, self.name, "big")
      player:broadcastSkillInvoke(self.name,2)
      local a = 0
      while true do
        if a == 6 then
          break
        end
        room:notifySkillInvoked(player, self.name, "negative")
        room:changeHp(player,1,nil,self.name)
        room:loseHp(player,1,self.name)
        room:delay(100)
        a = a + 1
      end
      player.room:killPlayer{
        who = player.id,
      }
    end
  end,
}

zonghuo_x:addRelatedSkill(zonghuo_y)
zonghuo_x:addRelatedSkill(zonghuo_z)
sk__mn:addSkill(zonghuo_x)
sk__mn:addSkill(zifen)
sk__mn:addSkill(fengjin)

Fk:loadTranslationTable{
  ["sk__mn"] = "猫宁",
  ["#sk__mn"] = "CS纵火犯",
  ["designer:sk__mn"] = "塔罗牌",
  ["cv:sk__mn"] = "猫宁",
  ["illustrator:sk__mn"] = "猫宁",

  ["zonghuo_x"] = "纵火",
  [":zonghuo_x"] = "①每轮开始时，你横置所有友方角色并使其获得【引火物】。一名角色受到火焰伤害时，其上下家获得【引火物】标记，然后若其未被横置，横置其<br>"..
  "②出牌阶段限一次，你可以弃置X张牌，对一名角色造成1点火焰伤害（X为场上人数-场上所有【引火物】之和，若等于0则改为摸2张牌）",
  ["@@mn_yhw"] = "引火物",
  ["$zonghuo_x1"] = "燃烧弹!",
  ["$zonghuo_x2"] = "呵呵呵呵哈哈",

  ["#zonghuo_z"] = "纵火",
  ["#zonghuo_y"] = "纵火",
  ["#zonghuo-a-active"] = "发动【纵火】，弃置 %arg 张牌，对一名角色造成1点火焰伤害",
  ["#zonghuo-b-active"] = "发动【纵火】，摸两张牌，对一名角色造成1点火焰伤害",
  ["#zonghuo-throw-ask"] = "请弃置 %arg 张牌",

  ["zifen"] = "自焚",
  [":zifen"] = "限定技，出牌阶段，你可以对所有有【引火物】的角色依次造成1点伤害，然后若该角色不为你，你失去1点体力",
  ["#zifen-active"] = "发动【自焚】，对所有有标记的角色造成1点普通伤害，但是自己也会掉血",
  ["$zifen"] = "额啊,来吧走起!",

  ["fengjin"] = "封禁",
  [":fengjin"] = "锁定技，当你对友方角色造成1点伤害后，若此时累计对友方角色造成：未满6点伤害时：你回复1点体力并摸一张牌；不小于7点：你死亡。"..
  "<br><font color='red'>村：很抱歉但是：若为身份模式，所有友方角色改为自身，纵火一样",
  ["@mn_fengjin"] = "封禁",
  ["$fengjin1"] = "烧队友，豪玩！",
  ["$fengjin2"] = "诶呦卧槽怎么被封号了",

  ["~sk__mn"] = "诶呦卧槽怎么被封号了",
}










local findDC = function (p)
  local DC = {}
  for _, c in ipairs(p:getCardIds(Player.Hand)) do
    local card = Fk:getCardById(c)
    if card.is_damage_card then
      table.insertIfNeed(DC, c)
    end
  end
  return DC
end



local sk__qlfc = General(jd, "sk__qlfc", "skeld", 3, 3,General.Male)


Fk:loadTranslationTable{
  ["sk__qlfc"] = "秦楼风吹",
  ["#sk__qlfc"] = "我有三千炼狱",
  ["designer:sk__qlfc"] = "塔罗牌",
  ["cv:sk__qlfc"] = "秦楼风吹",
  ["illustrator:sk__qlfc"] = "秦楼风吹",
}

local shenpan = fk.CreateActiveSkill{
  name = "shenpan",
  prompt = "#shenpan",
  anim_type = "control",
  target_num = 1,
  mute = true,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards, _, _, player)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0 and to_select ~= player.id and
    not target:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:notifySkillInvoked(player,self.name,"control")
    player:broadcastSkillInvoke(self.name,1)
    room:doIndicate(player.id, {target.id})
    U.viewCards(player, target:getCardIds("h"), self.name, "$ViewCardsFrom:"..target.id)
    local all_choices = {"giveDC","beigao","give2","Cancel"}
    local all_choice = {"giveDC","beigao","give2"}
    local remove_c = room:askForChoice(player,all_choices,self.name,"shenpan-remove")
    local real_choices = {}
    local DC = findDC(target)
    if #DC > 0 then
      if remove_c ~= "giveDC" then
        table.insertIfNeed(real_choices,"giveDC")
      end
      if remove_c == "giveDC" or remove_c == "Cancel" then
        table.insertIfNeed(real_choices,"give2")
        table.insertIfNeed(real_choices,"beigao")
      end
      if remove_c == "beigao" then
        table.insertIfNeed(real_choices,"give2")
      elseif remove_c == "give2" then
        table.insertIfNeed(real_choices,"beigao")
      end
    else
      if remove_c == "giveDC" or remove_c == "Cancel" then
        table.insertIfNeed(real_choices,"give2")
        table.insertIfNeed(real_choices,"beigao")
      end
      if remove_c == "beigao" then
        table.insertIfNeed(real_choices,"give2")
      elseif remove_c == "give2" then
        table.insertIfNeed(real_choices,"beigao")
      end
    end
    local choice = room:askForChoice(target,real_choices,self.name,"shenpan-choice",nil,all_choice)
    if choice == "giveDC" then
      room:addPlayerMark(player,"shenpan_c_1",1)
      local DC = findDC(target)
      if #DC > 0 then
        room:moveCards({
          ids = DC,
          from = target.id,
          to = player.id,
          toArea = Card.PlayerHand,
          moveReason = fk.ReasonGive,
          skillName = self.name,
          moveVisible = false
        })
      end
    elseif choice == "beigao" then
      room:addPlayerMark(player,"shenpan_c_1",1)
      room:setPlayerMark(target,"@@shenpan_beigao",1)
      room:setPlayerMark(target,"shenpan_beigao",player.id)
    else
      room:addPlayerMark(player,"shenpan_c_2",1)
      local cards = room:askForCard(target, math.min(2,#target:getCardIds(Player.Hand)), 2, true, self.name, false, ".", "#shenpan-give2c")
      if #cards > 0 then
        room:moveCards({
          ids = cards,
          from = target.id,
          to = player.id,
          toArea = Card.PlayerHand,
          moveReason = fk.ReasonGive,
          skillName = self.name,
          moveVisible = false
        })
      end
    end
  end,
}

local shenpan_beigao = fk.CreateTriggerSkill{
  name = "#shenpan_beigao",
  anim_type = "special",
  frequency = Skill.Compulsory,
  mute = true,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return target:getMark("@@shenpan_beigao") ~= 0
  end,
  on_trigger = function(self, event, target, player, data)
    local DC = findDC(target)
    local room = target.room
    local player = room:getPlayerById(target:getMark("shenpan_beigao"))
    room:notifySkillInvoked(target,self.name,"negative")
    if #DC == 0 then return room:setPlayerMark(target,"@@shenpan_beigao",0) end
    if #DC ~= 0 then
      room:loseHp(target,1,self.name)
      room:setPlayerMark(target,"@@shenpan_beigao",0)
      player:broadcastSkillInvoke("shenpan",-1)
      local choices = {"fanmian","givecard"}
      local choice = room:askForChoice(target,choices,self.name,"beigao-choice")
      if choice == "givecard" then
        room:notifySkillInvoked(target,self.name,"control")
        player:broadcastSkillInvoke("shenpan",3)
        room:doIndicate(target.id,{player.id})
        local cards = target:getCardIds("h")
        room:moveCards({
          ids = cards,
          from = target.id,
          to = player.id,
          toArea = Card.PlayerHand,
          moveReason = fk.ReasonGive,
          skillName = self.name,
          moveVisible = false
        })
      else
        room:notifySkillInvoked(target,self.name,"control")
        player:broadcastSkillInvoke("shenpan",2)
        room:doIndicate(target.id,{player.id})
        target:turnOver()
      end
    end
  end,
}

Fk:loadTranslationTable{
  ["shenpan"] = "审判",
  [":shenpan"] = "出牌阶段限一次，你可以观看一名其他角色的手牌，然后其选择一项：1.交给你所有伤害类牌 2.成为【被告】 3.交给你两张牌；其选择前，你可以移除其中的一项。",
  ["giveDC"] = "交出所有伤害牌",
  ["beigao"] = "成为【被告】",
  ["give2"] = "交出两张手牌",
  ["fanmian"] = "翻面",
  ["givecard"] = "交出所有手牌",
  ["#shenpan"] = "审判：你可以选择一名有手牌的角色，然后观看其手牌并使其执行效果",
  ["$shenpan1"] = "诶 我很好奇你有我的B动静吗",
  ["$shenpan2"] = "还发是吧，跪下！",
  ["$shenpan3"] = "过来！",

  ["#shenpan-give2c"] = "请交出两张手牌",
  ["shenpan-choice"] = "请选择一项",
  ["shenpan-remove"] = "你可以移除其中的一项",
  ["@@shenpan_beigao"] = "被告",
  ["#shenpan_beigao"] = "审判",
  ["beigao-choice"] = "请选择一项",
}

shenpan:addRelatedSkill(shenpan_beigao)
sk__qlfc:addSkill(shenpan)




local qlfc__zimou = fk.CreateTriggerSkill{
  name = "qlfc__zimou",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return
      target == player and
      player:hasSkill(self) and
      player.phase == Player.Play and
      table.contains({ 2, 4, 6 }, player:getMark("@" .. self.name))
  end,
  on_use = function(self, event, player, target, data)
    local count = player:getMark("@" .. self.name)

    local cardList = "analeptic"
    if count == 4 then
      cardList = "slash"
    elseif count == 6 then
      cardList = "duel"
    end
    local randomCard = player.room:getCardsFromPileByRule(cardList)
    if #randomCard > 0 then
      player.room:moveCards({
        ids = { randomCard[1] },
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonPrey,
        proposer = player.id,
        skillName = self.name,
      })
    end
  end,

  refresh_events = {fk.PreCardUse,fk.TurnEnd},
  can_refresh = function(self, event, target, player, data)
    if event == fk.TurnEnd then
      return player:hasSkill(self) and target == player
    else
      return player:hasSkill(self) and target == player and player.phase == Player.Play
    end
  end,
  on_refresh = function(self, event, target, player, data)
    if event == fk.TurnEnd then
      player.room:setPlayerMark(player, "@" .. self.name, 0)
    else
      player.room:addPlayerMark(player, "@" .. self.name, 1)
    end
  end,
}


Fk:loadTranslationTable{
  ["qlfc__zimou"] = "自谋",
  [":qlfc__zimou"] = "锁定技，当你于出牌阶段内使用：第二张牌时，你随机获得一张【酒】；第四张牌时，你随机获得一张【杀】；第六张牌时，"..
  "你随机获得一张【决斗】。",
  ["@qlfc__zimou"] = "自谋",
  ["$qlfc__zimou"] = "过来！",
}

local qlfc__qingjian = fk.CreateTriggerSkill{
  name = "qlfc__qingjian",
  anim_type = "drawcard",
  events = {fk.AfterCardsMove, fk.EventPhaseEnd},
  can_trigger = function (self, event, target, player, data)
    if event == fk.AfterCardsMove then
      return
        player:hasSkill(self) and
        #player:getPile("qlfc__qingjian") < math.max(player.hp - 1, 1) and
        table.find(
          data,
          function(info)
            return
              (info.moveReason ~= fk.ReasonUse or not player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)) and
              info.toArea == Card.DiscardPile and
              table.find(info.moveInfo, function(moveInfo) return player.room:getCardArea(moveInfo.cardId) == Card.DiscardPile end)
          end
        )
    else
      return target == player and player:hasSkill(self) and player.phase == Player.Play and #player:getPile("qlfc__qingjian") > 0
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    if event == fk.AfterCardsMove then
      local toPut = {}
      for _, info in ipairs(data) do
        if
          (info.moveReason ~= fk.ReasonUse or not room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)) and
          info.toArea == Card.DiscardPile
        then
          local cardsInDiscardPile = table.filter(
            info.moveInfo,
            function(moveInfo) return room:getCardArea(moveInfo.cardId) == Card.DiscardPile end
          )

          local diff = math.max(player.hp - 1, 1) - #player:getPile("qlfc__qingjian")
          if #cardsInDiscardPile > 0 then
            table.insertTable(
              toPut,
              table.map(
                table.slice(cardsInDiscardPile, 1, diff + 1),
                function(moveInfo) return moveInfo.cardId end
              )
            )

            if #toPut >= diff then
              break
            end
          end
        end
      end

      player:addToPile("qlfc__qingjian", toPut, true, self.name)
    else
      local num = #player:getPile("qlfc__qingjian")
      room:askForYiji(player, player:getPile("qlfc__qingjian"), nil, self.name, num, num, nil, "qlfc__qingjian")
    end
  end,
}
Fk:loadTranslationTable{
  ["qlfc__qingjian"] = "清俭",
  [":qlfc__qingjian"] = "当一张牌不因使用而进入弃牌堆后，若你的“清俭”数不大于X（X为你的体力值-1，且至少为1），则你将此牌置于你的武将牌上，" ..
  "称为“清俭”；出牌阶段结束时，你将你的所有“清俭”分配给任意角色。",
  ["$qlfc__qingjian1"] = "干嘛呀",
  ["$qlfc__qingjian2"] = "诶",
}

sk__qlfc:addRelatedSkill(qlfc__zimou)
sk__qlfc:addRelatedSkill(qlfc__qingjian)



local biane = fk.CreateTriggerSkill{
  name = "biane",
  frequency = Skill.Wake,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish and
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    return player:usedSkillTimes("shenpan", Player.HistoryGame) >= player.hp
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMark("shenpan_c_1") > player:getMark("shenpan_c_2") then
      room:notifySkillInvoked(player,self.name,"support")
      room:handleAddLoseSkills(player,"-shenpan|shenpan_two",nil)
      room:handleAddLoseSkills(player,"qlfc__qingjian",nil)
    else
      room:notifySkillInvoked(player,self.name,"negative")
      room:handleAddLoseSkills(player,"-shenpan|shenpan_three",nil)
      room:handleAddLoseSkills(player,"qlfc__zimou",nil)
    end      
    local all_choices = {"recover","maxHp"}
    local choices = {}
    if player:isWounded() then
      table.insert(choices,"recover")
    end
    table.insert(choices,"maxHp")
    local choice = room:askForChoice(player,choices,self.name,"biane-choice",nil,all_choices)
    if choice == "recover" then
      room:recover{ who = player, num = 1, skillName = self.name }
    else
      room:changeMaxHp(player, 1)
    end
  end,
}

Fk:loadTranslationTable{
  ["biane"] = "辨恶",
  [":biane"] = "觉醒技，结束阶段，若你至少发动过X次【审判】，若【审判】选择1，2选项次数总和大于3选项的次数，你获得【清俭】，然后将【审判】升级至2级：否则你获得【自谋】，然后将【审判】升级至3级。最后你可以选择增加一点体力上限或回复1点体力。（X为你的体力值）",
  ["$biane1"] = "为自己的选择负责，另一方面，之后他们回想起这段经历...",
  ["recover"] = "回复1点体力",
  ["maxHp"] = "增加1点体力上限",
  ["biane-choice"] = "请选择一项",
}

sk__qlfc:addSkill(biane)











local shenpan_two = fk.CreateActiveSkill{
  name = "shenpan_two",
  prompt = "#shenpan_two",
  anim_type = "control",
  min_target_num = 1,
  max_target_num = 3,
  mute = true,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards, _, _, player)
    return to_select ~= player.id and
    not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:sortPlayersByAction(effect.tos)
    local showMap = {}
    for _, pid in ipairs(effect.tos) do
      local p = room:getPlayerById(pid)
      if not (p.dead or p:isKongcheng()) then
        local id = table.random(p:getCardIds(Player.Hand))
        table.insert(showMap, {pid, id})
      end
    end
    for _, value in ipairs(showMap) do
      local target = room:getPlayerById(value[1])
      room:notifySkillInvoked(target,self.name,"control")
      player:broadcastSkillInvoke(self.name,1)
      room:doIndicate(player.id,{target.id})
      U.viewCards(player, target:getCardIds("h"), self.name, "$ViewCardsFrom:"..target.id)
      local all_choices = {"giveDC2","beigao2"}
      local choice = room:askForChoice(target,all_choices,self.name,"shenpan-choice")
      if choice == "giveDC2" then
        local DC = findDC(target)
        if #DC > 0 then
          room:moveCards({
            ids = DC,
            from = target.id,
            to = player.id,
            toArea = Card.PlayerHand,
            moveReason = fk.ReasonGive,
            skillName = self.name,
            moveVisible = false
          })
        else
          room:setPlayerMark(target,"@@shenpan_two_skip",1)
        end
      else
        room:setPlayerMark(target,"@@shenpan_beigao",1)
        if #target:getCardIds("h") > 1 then
          local canDiscard = table.filter(target:getCardIds("h"), function(id) return not target:prohibitDiscard(Fk:getCardById(id)) end)
          if #canDiscard then
            room:throwCard(table.random(canDiscard, 2), self.name, target, target)
          end
        else
          local canDiscard = table.filter(target:getCardIds("h"), function(id) return not target:prohibitDiscard(Fk:getCardById(id)) end)
          if #canDiscard then
            room:throwCard(table.random(canDiscard, 1), self.name, target, target)
          end
        end
      end
    end
  end,
}

local shenpan_two_delay = fk.CreateTriggerSkill{
  name = "#shenpan_two_delay",
  events = {fk.EventPhaseChanging},
  priority = 10,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target:getMark("@@shenpan_two_skip") > 0 and data.to == Player.Play
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(target,self.name,"control")
    player:broadcastSkillInvoke("shenpan_two",2)
    room:doIndicate(player.id,{target.id})
    player.room:setPlayerMark(target, "@@shenpan_two_skip", 0)
    target:skip(Player.Play)
    return true
  end,
}
shenpan_two:addRelatedSkill(shenpan_two_delay)

local shenpan_two_delay2 = fk.CreateTriggerSkill{
  name = "#shenpan_two_delay2",
  events = {fk.EventPhaseChanging},
  priority = 10,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target:getMark("@@shenpan_two_skip") > 0 and data.to == Player.Discard
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(target,self.name,"control")
    player:broadcastSkillInvoke("shenpan_two",3)
    room:doIndicate(player.id,{target.id})
    player.room:setPlayerMark(target, "@@shenpan_two_skip", 0)
    target:skip(Player.Discard)
    return true
  end,
}
shenpan_two:addRelatedSkill(shenpan_two_delay2)

Fk:loadTranslationTable{
  ["shenpan_two"] = "审判",
  [":shenpan_two"] = "出牌阶段限一次，你可以依次观看至多三名其他角色的手牌，然后其选择一项：1.交给你所有伤害类牌，若其中不包含伤害牌，其跳过其下一个出牌阶段和弃牌阶段 2.成为【被告】并随机弃置两张手牌。",
  ["giveDC2"] = "交出所有伤害牌",
  ["beigao2"] = "成为【被告】",
  ["#shenpan_two"] = "审判：你可以选择至多3名有手牌的角色，然后观看其手牌并使其执行效果",

  ["$shenpan_two1"] = "诶 我很好奇你有我的B动静吗",
  ["$shenpan_two2"] = "还发是吧，跪下！",
  ["$shenpan_two3"] = "过来！",

  ["shenpan-choice"] = "请选择一项",
  ["@@shenpan_two_skip"] = "审判 跳过",
  ["#shenpan_beigao"] = "审判",
}

local shenpan_three = fk.CreateActiveSkill{
  name = "shenpan_three",
  prompt = "#shenpan_three",
  anim_type = "control",
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < player.hp
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards, _, _, player)
    return to_select ~= player.id and
    not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    U.viewCards(player, target:getCardIds("h"), self.name, "$ViewCardsFrom:"..target.id)
    local all_choices = {"beigao3","givecard3"}
    local choices = {}
    if target:getMark("@@shenpan_beigao") ~= 1 then
      table.insertIfNeed(choices,"beigao3")
    end
    table.insertIfNeed(choices,"givecard3")
    local choice = room:askForChoice(target,choices,self.name,"shenpan-choice",nil,all_choices)
    if choice == "givecard3" then
      local cards = room:askForCard(target, math.min(2,#target:getCardIds(Player.Hand)), 2, true, self.name, false, ".", "#shenpan-give2c")
      if #cards > 0 then
        room:moveCards({
          ids = cards,
          from = target.id,
          to = player.id,
          toArea = Card.PlayerHand,
          moveReason = fk.ReasonGive,
          skillName = self.name,
          moveVisible = false
        })
      end
    else
      room:setPlayerMark(target,"@@shenpan_beigao",1)
      room:loseHp(target,1,self.name)
    end
  end,
}



Fk:loadTranslationTable{
  ["shenpan_three"] = "审判",
  [":shenpan_three"] = "出牌阶段限X次，你可以观看一名其他角色的手牌，然后其选择一项：1.成为【被告】并失去1点体力；2.交给你两张牌。（X为你的体力值）",
  ["givecard3"] = "交出两张手牌",
  ["beigao3"] = "成为【被告】并失去1点体力",
  ["#shenpan_three"] = "审判：你可以选择1名有手牌的角色，然后观看其手牌并使其执行效果",

  ["$shenpan_three1"] = "还发是吧，跪下！",
  ["$shenpan_three2"] = "过来！",


  ["shenpan-choice"] = "请选择一项",
  ["#shenpan_beigao"] = "审判",
}



shenpan_two:addRelatedSkill(shenpan_beigao)
shenpan_three:addRelatedSkill(shenpan_beigao)
sk__qlfc:addSkill(shenpan)
sk__qlfc:addRelatedSkill(shenpan_two)
sk__qlfc:addRelatedSkill(shenpan_three)






return jd